Menu:

7-Mar-2008 Latest component update.

LinkLabel

component iconJLinkLabel is a web link-like Swing label component. It allows customization of the link color, the hover color when the cursor is over the link and the press color when the link is pressed. A hand cursor appears when the cursor moves over the link to indicate that it can be pressed. The JLinkLabel class extends the Swing JLabel component.

default colors
The default link, hover and pressed colors

Creation

public JLinkLabel()
public JLinkLabel(Color linkColor, 
	Color hoverColor, 
	Color pressColor)

The default constructor creates a link label using common web colors while the second contructor allows you to specify custom link, hover and press colors.

Methods

public void setLinkColor(Color color)
public Color getLinkColor()
public void setHoverColor(Color color)
public Color getHoverColor()
public void setPressColor(Color color)
public Color getPressColor()

public void setText(String text)
public String getText()

The provided accessors allow you to read and update the color and text information of a JLinkLabel object.

Events

public void addActionListener(ActionListener listener)
public void removeActionListener(ActionListener listener)
public void setActionCommand(String command)

Get a notification for a click event by adding an ActionListener to the JLinkLabel object. The generated ActionEvent has this JLinkLabel object as the source, an id of 0 and a JLinkLabel.LINK_ACTION or custom command text.