URLButtonpublic class URLButton extends Label implements MouseListenerURLButton -- a Button-like object that jumps to a URL.
MUST have an Applet parent since we use Applet methods. |
Fields Summary |
---|
Applet | parentApplet parent, for showStatus() and showDocument(). | String | tText to display in label() | URL | uURL 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 void | mouseClicked(java.awt.event.MouseEvent e)NotUsed
parent.showStatus("in mouseClicked");
| public void | mouseEntered(java.awt.event.MouseEvent e)When mouse enters, showStatus of URL
parent.showStatus(u.toExternalForm());
| public void | mouseExited(java.awt.event.MouseEvent e)When mouse enters, clear showStatus
parent.showStatus("");
| public void | mousePressed(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 void | mouseReleased(java.awt.event.MouseEvent e)NotUsed
parent.showStatus("in mouseReleased");
| public void | paint(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);
|
|