FileDocCategorySizeDatePackage
URLButton.javaAPI DocExample1672Sun Dec 27 15:20:34 GMT 1998None

URLButton

public class URLButton extends Label implements MouseListener
URLButton -- a Button-like object that jumps to a URL. MUST have an Applet parent since we use Applet methods.

Fields Summary
Applet
parent
Applet parent, for showStatus() and showDocument().
String
t
Text to display in label()
URL
u
URL to jump to mouseReleased mouseEnter()
Constructors Summary
URLButton(Applet parent, String t, URL u)
Construct a URLButton given a URL

		super(t);
		this.parent = parent;
		this.t = t;
		this.u = u;
		addMouseListener(this);
	
Methods Summary
public voidmouseClicked(java.awt.event.MouseEvent e)
NotUsed

		parent.showStatus("in mouseClicked");
	
public voidmouseEntered(java.awt.event.MouseEvent e)
When mouse enters, showStatus of URL

		parent.showStatus(u.toExternalForm());
	
public voidmouseExited(java.awt.event.MouseEvent e)
When mouse enters, clear showStatus

		parent.showStatus("");
	
public voidmousePressed(java.awt.event.MouseEvent e)
When the button is pressed, go for it!

		parent.showStatus("Showing document at URL " + u);

		parent.getAppletContext().showDocument(u);
		// No error checking on showDocument() -- the
		// browser will honk at the user if the link
		// is invalid. We should open "u" ourselves,
		// check the open, and close it. Or not...
	
public voidmouseReleased(java.awt.event.MouseEvent e)
NotUsed

		parent.showStatus("in mouseReleased");
	
public voidpaint(java.awt.Graphics g)
paint() method just draws a box around us

		// super.paint(graphics g);
		Dimension d = getSize();
		g.drawRect(0, 0, d.width-1, d.height-1);