Link to home
Start Free TrialLog in
Avatar of imwalt
imwalt

asked on

Hyperlink a Java Applet???

Is it possible to make a java applet goto a link when clicked on?  I've seen some that go places, just not the one I'm using.  Maybe add a hyperlink or something?

I'm not a programmer, and basically have no clue what I'm doing, so hopefully it isn't too complicated.

I figure this should be an easy question for you guys.  If it is possible, and you can tell me how to do it in both html and FrontPage, that would be great!!  I'd probably be enticed to increase my points given.

Thanks
-WALTERisME@home.com
Avatar of TimYates
TimYates
Flag of United Kingdom of Great Britain and Northern Ireland image

you have to edit the source code of the applet.  You cannot put hyperlinks on applets :-(

If you put this into the applet's java file:

  public boolean mouseUp( Event evt, int x, int y )
  {
    AppletContext context = getAppletContext() ;
    context.showDocument( "https://www.experts-exchange.com" ) ;
    return true ;
  }

and compile the applet again (this is JDK 1.0.2 compliant)

then clicking on it will bring you to experts exchange

Good Luck,

Tim
Avatar of imwalt
imwalt

ASKER

You said:
If you put this into the applet's java file:

 public boolean mouseUp( Event evt, int x, int y )
 {
   AppletContext context = getAppletContext() ;
   context.showDocument( "https://www.experts-exchange.com" ) ;
   return true ;
 }

Great!! But what is the applet's java file?  I have two to choose from.  Is it a .class or a .jad?  And does it matter where it goes inside the file?
jmwalt,

   when u say an applet's java file, this means the code u wrote (those save in .java file e.g. myJava.java). when u compile this java file using javac (javac.exe - java compiler), this creates a .class file (myJava.class).

e.g.
     myJava.java  // java source file
     javac myJava.java //creates a myJava.class


it only depends if u declared your source as an ordinary java application or a java applet(those seen in web browsers). to make a java applet, your program should inherit the java.applet class(built-java class).


those file in .jar (not .jad), is an archive of all classes. this is compiled using the jar (jar.exe). so a .jar file consists of several classes. e.g.
     myJar.jar has myJava.class, yourJava.class, etc...


just in case u really have this .jad file, these are source files decompiled by a java decompiler(i have seen one decompiler saves it in .jad file). so if u have this file, u need to rename it to .java file so that the java compiler can recognize ur source (rename myJava.jad to myJava.java).

more on applets, click here:

  http://java.sun.com/docs/books/tutorial/applet/TOC.html


gud luck! :)
ASKER CERTIFIED SOLUTION
Avatar of TimYates
TimYates
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
.jad files are created by an app called "JAD" which is a java decompiler
imwalt:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
No comment has been added lately, so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area that this question is:

- Points for TimYates

Please leave any comments here within the next seven days.
 
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!
 
Venabili
EE Cleanup Volunteer