Solved

Hyperlink a Java Applet???

Posted on 2001-08-08
8
1,334 Views
Last Modified: 2013-11-23
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
0
Comment
Question by:imwalt
8 Comments
 
LVL 35

Expert Comment

by:TimYates
ID: 6367146
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( "http://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
0
 
LVL 30

Expert Comment

by:third
ID: 6367160
0
 

Author Comment

by:imwalt
ID: 6369431
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( "http://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?
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 30

Expert Comment

by:third
ID: 6370530
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! :)
0
 
LVL 35

Accepted Solution

by:
TimYates earned 25 total points
ID: 6371644
>> ?  I have two to choose from.  Is it a .class or a .jad?  


Hee hee..  rename the .jad file to .java

you will have something which when you open it in a text editor has something like:

public class XXXXXX extends Applet
{

  //loads of code here...

  // put it here
}

you put that method where the "put it here line" is in the above pseudo code...

then compile it with

javac blah.java

then you should be able to put that as an applet onto your webpage...

make sure you are using JDK1.1.8 or JDK1.0.2 (both downloadable from the API section of http://java.sun.com )

As browsers don't support higher JDK's (unless you have installed a plugin)

Good Luck!

Tim.
0
 
LVL 35

Expert Comment

by:TimYates
ID: 6371648
.jad files are created by an app called "JAD" which is a java decompiler
0
 

Expert Comment

by:CleanupPing
ID: 9061902
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.
0
 
LVL 20

Expert Comment

by:Venabili
ID: 9329915
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
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Weekend adv creator 3 38
oracle 11g 23 80
sql import cannot be resolved jsp 3 20
eclipse console opening separately 2 18
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Java functions are among the best things for programmers to work with as Java sites can be very easy to read and prepare. Java especially simplifies many processes in the coding industry as it helps integrate many forms of technology and different d…
Viewers learn how to read error messages and identify possible mistakes that could cause hours of frustration. Coding is as much about debugging your code as it is about writing it. Define Error Message: Line Numbers: Type of Error: Break Down…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question