public class SmartIconJButton
extends java.lang.Object
implements javax.swing.Icon, java.beans.PropertyChangeListener
As JTabbedPanes cannot use any JComponents as tab selectors (the access if protected and we just have a label, an icon and a tooltip), we have to rely on tricks to bypass them.
This trick, the SmartIconJButton is an icon faking the behaviour of a button. It uses an Action for reacting to clicks and manages a set of images (default, rollover, pressed, disabled) to behave like a rollover button.
Modifier and Type | Field and Description |
---|---|
protected javax.swing.Action |
action
The action triggered when the clicks on the icon
|
protected javax.swing.Icon |
defaultIcon
the default icon (enabled/visible)
|
protected javax.swing.Icon |
disabledIcon
the icon for the disabled effect
|
protected javax.swing.Icon |
pressedIcon
the icno for the pressed effect
|
protected javax.swing.Icon |
rolloverIcon
the icon for the rollover effect
|
protected java.lang.String |
tooltipText
the tooltip associated with the button
|
Constructor and Description |
---|
SmartIconJButton(javax.swing.Action action)
Constructs a new button with an action.
|
Modifier and Type | Method and Description |
---|---|
void |
fireAction(java.awt.event.ActionEvent e)
triggers the associated action
|
javax.swing.Icon |
getDisabledIcon()
Returns the disabled icon
|
javax.swing.Icon |
getIcon()
Returns the default icon
|
int |
getIconHeight() |
int |
getIconWidth() |
javax.swing.Icon |
getPressedIcon()
Returns the pressed icon
|
javax.swing.Icon |
getRolloverIcon()
Returns the rollover icon
|
java.lang.String |
getTooltipText() |
boolean |
isEnabled()
Returns the enabled state
|
boolean |
isPressed()
Returns the pressed state
|
boolean |
isRollover()
Returns the rollover state
|
boolean |
isVisible()
Returns the visible state
|
void |
paintIcon(java.awt.Component c,
java.awt.Graphics g,
int x,
int y)
paints the appropriate icon according to its internal state (pressed, rollover...)
|
void |
propertyChange(java.beans.PropertyChangeEvent evt)
Do not call directly as it a side effect of listening to the action changes.
|
void |
setDisabledIcon(javax.swing.Icon icon)
Update the disabled icon property
|
void |
setEnabled(boolean isEnabled)
Update the enabled state
|
void |
setIcon(javax.swing.Icon icon)
Update the default icon property
|
void |
setPressed(boolean isPressed)
Update the pressed state
|
void |
setPressedIcon(javax.swing.Icon icon)
Update the pressed icon property
|
void |
setRollover(boolean isRollover)
Update the rollover state
|
void |
setRolloverIcon(javax.swing.Icon icon)
Update the rollover icon property
|
void |
setTooltipText(java.lang.String tooltip) |
void |
setVisible(boolean isVisible)
Update the visible state
|
protected javax.swing.Action action
protected javax.swing.Icon defaultIcon
protected javax.swing.Icon rolloverIcon
protected javax.swing.Icon pressedIcon
protected javax.swing.Icon disabledIcon
protected java.lang.String tooltipText
public SmartIconJButton(javax.swing.Action action)
public void setIcon(javax.swing.Icon icon)
public javax.swing.Icon getIcon()
public void setRolloverIcon(javax.swing.Icon icon)
public javax.swing.Icon getRolloverIcon()
public void setPressedIcon(javax.swing.Icon icon)
public javax.swing.Icon getPressedIcon()
public void setDisabledIcon(javax.swing.Icon icon)
public javax.swing.Icon getDisabledIcon()
public void setRollover(boolean isRollover)
public void setEnabled(boolean isEnabled)
public void setVisible(boolean isVisible)
public void setPressed(boolean isPressed)
public boolean isRollover()
public boolean isPressed()
public boolean isEnabled()
public boolean isVisible()
public void paintIcon(java.awt.Component c, java.awt.Graphics g, int x, int y)
paintIcon
in interface javax.swing.Icon
public int getIconWidth()
getIconWidth
in interface javax.swing.Icon
public int getIconHeight()
getIconHeight
in interface javax.swing.Icon
public void fireAction(java.awt.event.ActionEvent e)
public java.lang.String getTooltipText()
public void setTooltipText(java.lang.String tooltip)
public void propertyChange(java.beans.PropertyChangeEvent evt)
propertyChange
in interface java.beans.PropertyChangeListener
Copyright © 2010-2014 Pacific Biosciences. All Rights Reserved.