The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
January 2001

Advertisement

Advertisement

This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.

Message:

you can do it in JDk1.1

Posted by Kishori Sharan on January 31, 2001 at 1:27 PM

You can still use it. Just use Label instead of JLabel. YOu can change the color of the text in Label so that it may look different. I don't know how to underline a text in JDK v1.1 . You can also try to underline the text. Or, you can try it by dwawing a the text on a panel and th edraw a line of the same size as the text below it and write the same clicked event


////////////////////////

import java.net.* ;
import java.awt.*;
import java.awt.event.*;
import java.applet.* ;


public class Applet1 extends Applet {
Label lb = new Label ( "Go to Yahoo" ) ;

public void init ( ) {
add ( lb ) ;
add ( new Button ( "Does nothing" ) ) ;
// Change the mouse cursor
lb.setCursor ( new Cursor ( Cursor.HAND_CURSOR )) ;

// Set the color of label as blue and underline it so that
// it looks as a link
lb.setForeground ( Color.blue ) ;

lb.addMouseListener (
new MouseAdapter ( ) {
public void mouseClicked ( MouseEvent e ) {
try {
AppletContext ac = Applet1.this.getAppletContext ( ) ;
URL url = new URL ( "http://www.yahoo.com" ) ;
ac.showDocument ( url ) ;
}
catch ( Exception ex ) { }
}
}
);
}

}



Replies:

Sponsored Links



Google
  Web Artima.com   
Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us