edu.iastate.utils.gui
Class HyperlinkedLabel

java.lang.Object
  extended byjava.awt.Component
      extended byjava.awt.Label
          extended byedu.iastate.utils.gui.HyperlinkedLabel
All Implemented Interfaces:
javax.accessibility.Accessible, java.util.EventListener, java.awt.image.ImageObserver, java.awt.MenuContainer, java.awt.event.MouseListener, java.io.Serializable

public class HyperlinkedLabel
extends java.awt.Label
implements java.awt.event.MouseListener

A HyperlinkedLabel object is a component for placing a hyperlink into a container. A HyperlinkedLabel displays a single line of read-only text, which is underlined to give the visual impression of a hyperlink. Clicking on the hyperlink will produce no result however. It is up to the application developer to provide this functionality, such as performing an action, displaying a web page, or activating a menu.

Applications can catch hyperlink clicks by adding registering an ActionListener, using the addActionListener method.

Version:
1.00 10/5/99
Author:
David Reilly
See Also:
ActionEvent, ActionListener, Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.awt.Label
java.awt.Label.AccessibleAWTLabel
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
(package private)  java.awt.event.ActionListener actionListener
           
(package private)  boolean clicked
           
private  java.awt.Color hyperlinkColor
           
private  java.awt.Color originalTextColor
           
private  java.lang.String URL
           
 
Fields inherited from class java.awt.Label
CENTER, LEFT, RIGHT
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
HyperlinkedLabel(java.lang.String label)
          Creates a hyperlinked label with no specific hyperlink
HyperlinkedLabel(java.lang.String label, java.lang.String URL)
          Creates a hyperlinked label hyperlinked to the specified URL.
HyperlinkedLabel(java.lang.String label, java.lang.String URL, java.awt.Color color)
          Creates a hyperlinked label hyperlinked to the specified URL, in the specific color.
 
Method Summary
 void addActionListener(java.awt.event.ActionListener listener)
          Adds the specified action listener to receive action events from this hyperlink.
 java.awt.Color getHyperlinkColor()
          Returns the color for this hyperlink.
 java.awt.Dimension getPreferredSize()
          Returns the preferred size of the hyperlink.
 java.lang.String getURL()
          Returns the URL for this hyperlink.
 void mouseClicked(java.awt.event.MouseEvent e)
           
 void mouseEntered(java.awt.event.MouseEvent e)
          Event handler for when the cursor enters the hyperlink
 void mouseExited(java.awt.event.MouseEvent e)
          Event handler for when the cursor leaves the hyperlink
 void mousePressed(java.awt.event.MouseEvent e)
           
 void mouseReleased(java.awt.event.MouseEvent e)
           
 void paint(java.awt.Graphics g)
          Paints the hyperlink
 void removeActionListener(java.awt.event.ActionListener listener)
          Removes the specified action listener from the list of action listeners associated with this hyperlink.
 void setHyperlinkColor(java.awt.Color color)
          Sets the color for this hyperlink.
 void setURL(java.lang.String URL)
          Sets the URL destination for this hyperlink.
 
Methods inherited from class java.awt.Label
addNotify, getAccessibleContext, getAlignment, getText, paramString, setAlignment, setText
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

URL

private java.lang.String URL

hyperlinkColor

private java.awt.Color hyperlinkColor

originalTextColor

private java.awt.Color originalTextColor

clicked

transient boolean clicked

actionListener

transient java.awt.event.ActionListener actionListener
Constructor Detail

HyperlinkedLabel

public HyperlinkedLabel(java.lang.String label)
Creates a hyperlinked label with no specific hyperlink

Parameters:
label - Text of label

HyperlinkedLabel

public HyperlinkedLabel(java.lang.String label,
                        java.lang.String URL)
Creates a hyperlinked label hyperlinked to the specified URL.

Parameters:
label - Text of label
URL - Universal Resource Locator (URL)

HyperlinkedLabel

public HyperlinkedLabel(java.lang.String label,
                        java.lang.String URL,
                        java.awt.Color color)
Creates a hyperlinked label hyperlinked to the specified URL, in the specific color.

Parameters:
label - Text of label
URL - Universal Resource Locator (URL)
color - Color of hyperlink
Method Detail

setURL

public void setURL(java.lang.String URL)
Sets the URL destination for this hyperlink.

Parameters:
URL - Universal Resource Locator (URL)

setHyperlinkColor

public void setHyperlinkColor(java.awt.Color color)
Sets the color for this hyperlink.

Parameters:
color - Color of hyperlink

getHyperlinkColor

public java.awt.Color getHyperlinkColor()
Returns the color for this hyperlink.

Returns:
Color of hyperlink

getURL

public java.lang.String getURL()
Returns the URL for this hyperlink.

Returns:
Universal Resource Locator (URL) as a String

paint

public void paint(java.awt.Graphics g)
Paints the hyperlink

Parameters:
g - Graphics object for painting

addActionListener

public void addActionListener(java.awt.event.ActionListener listener)
Adds the specified action listener to receive action events from this hyperlink.

Parameters:
listener - ActionListener to add to event queue

removeActionListener

public void removeActionListener(java.awt.event.ActionListener listener)
Removes the specified action listener from the list of action listeners associated with this hyperlink.

Parameters:
listener - ActionListener to add to event queue

mouseClicked

public void mouseClicked(java.awt.event.MouseEvent e)
Specified by:
mouseClicked in interface java.awt.event.MouseListener

mouseEntered

public void mouseEntered(java.awt.event.MouseEvent e)
Event handler for when the cursor enters the hyperlink

Specified by:
mouseEntered in interface java.awt.event.MouseListener

mouseExited

public void mouseExited(java.awt.event.MouseEvent e)
Event handler for when the cursor leaves the hyperlink

Specified by:
mouseExited in interface java.awt.event.MouseListener

mousePressed

public void mousePressed(java.awt.event.MouseEvent e)
Specified by:
mousePressed in interface java.awt.event.MouseListener

mouseReleased

public void mouseReleased(java.awt.event.MouseEvent e)
Specified by:
mouseReleased in interface java.awt.event.MouseListener

getPreferredSize

public java.awt.Dimension getPreferredSize()
Returns the preferred size of the hyperlink.

Returns:
Preferred dimensions