|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.AbstractButton
javax.swing.JButton
org.jdesktop.swingx.JXHyperlink
public class JXHyperlink
A hyperlink component that derives from JButton to provide compatibility mostly for binding actions enabled/disabled behavior accesilibity i18n etc...
This button has visual state related to a notion of "clicked":
foreground color is unclickedColor or clickedColor depending on
its boolean bound property clicked being false or true, respectively.
If the hyperlink has an action, it guarantees to synchronize its
"clicked" state to an action value with key LinkAction.VISITED_KEY.
Synchronization happens on setAction() and on propertyChange notification
from the action. JXHyperlink accepts any type of action -
AbstractHyperlinkAction
is a convenience implementation to
simplify clicked control.
LinkAction linkAction = new LinkAction("http://swinglabs.org") {
public void actionPerformed(ActionEvent e) {
doSomething(getTarget());
setVisited(true);
}
};
JXHyperlink hyperlink = new JXHyperlink(linkAction);
The hyperlink can be configured to always update its clicked
property after firing the actionPerformed:
JXHyperlink hyperlink = new JXHyperlink(action);
hyperlink.setOverrulesActionOnClick(true);
By default, this property is false. The hyperlink will
auto-click only if it has no action. Developers can change the
behaviour by overriding isAutoSetClicked()
;
Nested Class Summary |
---|
Nested classes/interfaces inherited from class javax.swing.JButton |
---|
JButton.AccessibleJButton |
Nested classes/interfaces inherited from class javax.swing.AbstractButton |
---|
AbstractButton.AccessibleAbstractButton, AbstractButton.ButtonChangeListener |
Nested classes/interfaces inherited from class javax.swing.JComponent |
---|
JComponent.AccessibleJComponent |
Nested classes/interfaces inherited from class java.awt.Container |
---|
Container.AccessibleAWTContainer |
Nested classes/interfaces inherited from class java.awt.Component |
---|
Component.AccessibleAWTComponent, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
---|---|
static String |
uiClassID
|
Fields inherited from class javax.swing.JComponent |
---|
accessibleContext, listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW |
Fields inherited from class java.awt.Component |
---|
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT |
Fields inherited from interface javax.swing.SwingConstants |
---|
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST |
Fields inherited from interface java.awt.image.ImageObserver |
---|
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
---|---|
JXHyperlink()
Creates a new instance of JXHyperlink with default parameters |
|
JXHyperlink(Action action)
Creates a new instance of JHyperLink and configures it from provided Action. |
Method Summary | |
---|---|
protected void |
configurePropertiesFromAction(Action a)
Read all the essentional properties from the provided Action
and apply it to the JXHyperlink |
protected PropertyChangeListener |
createActionPropertyChangeListener(Action a)
Creates and returns a listener that will watch the changes of the provided Action and will update JXHyperlink's properties
accordingly. |
protected void |
fireActionPerformed(ActionEvent event)
Notifies all listeners that have registered interest for notification on this event type. |
Color |
getClickedColor()
Returns the foreground color for visited links. |
boolean |
getOverrulesActionOnClick()
Returns a boolean indicating whether the clicked property should be set always on clicked. |
String |
getUIClassID()
Returns a string that specifies the name of the L&F class that renders this component. |
Color |
getUnclickedColor()
Returns the foreground color for unvisited links. |
protected boolean |
isAutoSetClicked()
Returns a boolean indicating whether the clicked property should be set after firing action events. |
boolean |
isClicked()
Returns a boolean indicating if this link has already been visited. |
void |
setClicked(boolean clicked)
Sets the clicked property and updates visual state depending on clicked. |
void |
setClickedColor(Color color)
Sets the color for the previously not visited link. |
void |
setOverrulesActionOnClick(boolean overrule)
Sets the overrulesActionOnClick property. |
void |
setUnclickedColor(Color color)
Sets the color for the previously visited link. |
void |
updateUI()
Notification from the UIManager that the L&F has changed. |
Methods inherited from class javax.swing.JButton |
---|
getAccessibleContext, isDefaultButton, isDefaultCapable, paramString, removeNotify, setDefaultCapable |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final String uiClassID
getUIClassID()
,
JComponent.readObject(java.io.ObjectInputStream)
,
Constant Field ValuesConstructor Detail |
---|
public JXHyperlink()
public JXHyperlink(Action action)
action
- Action whose parameters will be borrowed to configure newly
created JXHyperLinkMethod Detail |
---|
public Color getUnclickedColor()
public void setClickedColor(Color color)
color
- Color for the hyper link if it has not yet been clicked.public Color getClickedColor()
public void setUnclickedColor(Color color)
color
- Color for the hyper link if it has already been clicked.public void setClicked(boolean clicked)
NOTE: as with all button's visual properties, this will not update the backing action's "visited" state.
clicked
- flag to indicate if the button should be regarded as
having been clicked or not.isClicked()
public boolean isClicked()
true
if hyper link has already been clicked.setClicked(boolean)
public void setOverrulesActionOnClick(boolean overrule)
The default value is false
.
overrule
- if true, fireActionPerformed will set clicked to true
independent of action.getOverrulesActionOnClick()
,
setClicked(boolean)
public boolean getOverrulesActionOnClick()
setOverrulesActionOnClick(boolean)
,
setClicked(boolean)
protected void fireActionPerformed(ActionEvent event)
event
parameter. Overriden to respect the overrulesActionOnClick property.
fireActionPerformed
in class AbstractButton
event
- the ActionEvent
objectEventListenerList
protected boolean isAutoSetClicked()
protected PropertyChangeListener createActionPropertyChangeListener(Action a)
Action
and will update JXHyperlink's properties
accordingly.
createActionPropertyChangeListener
in class AbstractButton
a
- the new action for the buttonAction
,
AbstractButton.setAction(javax.swing.Action)
protected void configurePropertiesFromAction(Action a)
Action
and apply it to the JXHyperlink
configurePropertiesFromAction
in class JButton
a
- the Action
from which to get the
properties, or null
Action
,
AbstractButton.setAction(javax.swing.Action)
public String getUIClassID()
getUIClassID
in class JButton
JComponent.getUIClassID()
,
UIDefaults.getUI(javax.swing.JComponent)
public void updateUI()
UIManager
that the L&F has changed.
Replaces the current UI object with the latest version from the UIManager
.
updateUI
in class JButton
JComponent.updateUI()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |