com.vlsolutions.swing.tabbedpane

Class SmartIconJButton

public class SmartIconJButton extends Object implements Icon, PropertyChangeListener

A sub component of JTabbedPaneSmartIcon, used to describe a button included in a tabbedpane.

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.

Field Summary
protected Actionaction
The action triggered when the clicks on the icon
protected IcondefaultIcon
the default icon (enabled/visible)
protected IcondisabledIcon
the icon for the disabled effect
protected IconpressedIcon
the icno for the pressed effect
protected IconrolloverIcon
the icon for the rollover effect
protected StringtooltipText
the tooltip associated with the button
Constructor Summary
SmartIconJButton(Action action)
Constructs a new button with an action.
Method Summary
voidfireAction(ActionEvent e)
triggers the associated action
IcongetDisabledIcon()
Returns the disabled icon
IcongetIcon()
Returns the default icon
intgetIconHeight()
intgetIconWidth()
IcongetPressedIcon()
Returns the pressed icon
IcongetRolloverIcon()
Returns the rollover icon
StringgetTooltipText()
booleanisEnabled()
Returns the enabled state
booleanisPressed()
Returns the pressed state
booleanisRollover()
Returns the rollover state
booleanisVisible()
Returns the visible state
voidpaintIcon(Component c, Graphics g, int x, int y)
paints the appropriate icon according to its internal state (pressed, rollover...)
voidpropertyChange(PropertyChangeEvent evt)
Do not call directly as it a side effect of listening to the action changes.
voidsetDisabledIcon(Icon icon)
Update the disabled icon property
voidsetEnabled(boolean isEnabled)
Update the enabled state
voidsetIcon(Icon icon)
Update the default icon property
voidsetPressed(boolean isPressed)
Update the pressed state
voidsetPressedIcon(Icon icon)
Update the pressed icon property
voidsetRollover(boolean isRollover)
Update the rollover state
voidsetRolloverIcon(Icon icon)
Update the rollover icon property
voidsetTooltipText(String tooltip)
voidsetVisible(boolean isVisible)
Update the visible state

Field Detail

action

protected Action action
The action triggered when the clicks on the icon

defaultIcon

protected Icon defaultIcon
the default icon (enabled/visible)

disabledIcon

protected Icon disabledIcon
the icon for the disabled effect

pressedIcon

protected Icon pressedIcon
the icno for the pressed effect

rolloverIcon

protected Icon rolloverIcon
the icon for the rollover effect

tooltipText

protected String tooltipText
the tooltip associated with the button

Constructor Detail

SmartIconJButton

public SmartIconJButton(Action action)
Constructs a new button with an action. The button is enabled and visible.

Method Detail

fireAction

public void fireAction(ActionEvent e)
triggers the associated action

getDisabledIcon

public Icon getDisabledIcon()
Returns the disabled icon

getIcon

public Icon getIcon()
Returns the default icon

getIconHeight

public int getIconHeight()

getIconWidth

public int getIconWidth()

getPressedIcon

public Icon getPressedIcon()
Returns the pressed icon

getRolloverIcon

public Icon getRolloverIcon()
Returns the rollover icon

getTooltipText

public String getTooltipText()

isEnabled

public boolean isEnabled()
Returns the enabled state

isPressed

public boolean isPressed()
Returns the pressed state

isRollover

public boolean isRollover()
Returns the rollover state

isVisible

public boolean isVisible()
Returns the visible state

paintIcon

public void paintIcon(Component c, Graphics g, int x, int y)
paints the appropriate icon according to its internal state (pressed, rollover...)

propertyChange

public void propertyChange(PropertyChangeEvent evt)
Do not call directly as it a side effect of listening to the action changes.

setDisabledIcon

public void setDisabledIcon(Icon icon)
Update the disabled icon property

setEnabled

public void setEnabled(boolean isEnabled)
Update the enabled state

setIcon

public void setIcon(Icon icon)
Update the default icon property

setPressed

public void setPressed(boolean isPressed)
Update the pressed state

setPressedIcon

public void setPressedIcon(Icon icon)
Update the pressed icon property

setRollover

public void setRollover(boolean isRollover)
Update the rollover state

setRolloverIcon

public void setRolloverIcon(Icon icon)
Update the rollover icon property

setTooltipText

public void setTooltipText(String tooltip)

setVisible

public void setVisible(boolean isVisible)
Update the visible state
© Copyright 2004-2005 VLSolutions. All Rights Reserved.
www.vlsolutions.com : Java Components - Smart Client Applications