com.vlsolutions.swing.tabbedpane

Class SmartIconJButton

Implemented Interfaces:
Icon, PropertyChangeListener

public class SmartIconJButton
extends java.lang.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 Action
action
The action triggered when the clicks on the icon
protected Icon
defaultIcon
the default icon (enabled/visible)
protected Icon
disabledIcon
the icon for the disabled effect
protected Icon
pressedIcon
the icno for the pressed effect
protected Icon
rolloverIcon
the icon for the rollover effect
protected String
tooltipText
the tooltip associated with the button

Constructor Summary

SmartIconJButton(Action action)
Constructs a new button with an action.

Method Summary

void
fireAction(ActionEvent e)
triggers the associated action
Icon
getDisabledIcon()
Returns the disabled icon
Icon
getIcon()
Returns the default icon
int
getIconHeight()
int
getIconWidth()
Icon
getPressedIcon()
Returns the pressed icon
Icon
getRolloverIcon()
Returns the rollover icon
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, Graphics g, int x, int y)
paints the appropriate icon according to its internal state (pressed, rollover...)
void
propertyChange(PropertyChangeEvent evt)
Do not call directly as it a side effect of listening to the action changes.
void
setDisabledIcon(Icon icon)
Update the disabled icon property
void
setEnabled(boolean isEnabled)
Update the enabled state
void
setIcon(Icon icon)
Update the default icon property
void
setPressed(boolean isPressed)
Update the pressed state
void
setPressedIcon(Icon icon)
Update the pressed icon property
void
setRollover(boolean isRollover)
Update the rollover state
void
setRolloverIcon(Icon icon)
Update the rollover icon property
void
setTooltipText(String tooltip)
void
setVisible(boolean isVisible)
Update the visible state

Field Details

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 Details

SmartIconJButton

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

Method Details

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(java.awt.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-2006 VLSolutions. All Rights Reserved.
www.vlsolutions.com : Java Components - Smart Client Applications