com.vlsolutions.swing.tabbedpane
Class SmartIconJButton

java.lang.Object
  extended by com.vlsolutions.swing.tabbedpane.SmartIconJButton
All Implemented Interfaces:
java.beans.PropertyChangeListener, java.util.EventListener, javax.swing.Icon

public class SmartIconJButton
extends java.lang.Object
implements javax.swing.Icon, java.beans.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  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 Summary
SmartIconJButton(javax.swing.Action action)
          Constructs a new button with an action.
 
Method Summary
 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
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

action

protected javax.swing.Action action
The action triggered when the clicks on the icon


defaultIcon

protected javax.swing.Icon defaultIcon
the default icon (enabled/visible)


rolloverIcon

protected javax.swing.Icon rolloverIcon
the icon for the rollover effect


pressedIcon

protected javax.swing.Icon pressedIcon
the icno for the pressed effect


disabledIcon

protected javax.swing.Icon disabledIcon
the icon for the disabled effect


tooltipText

protected java.lang.String tooltipText
the tooltip associated with the button

Constructor Detail

SmartIconJButton

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

Method Detail

setIcon

public void setIcon(javax.swing.Icon icon)
Update the default icon property


getIcon

public javax.swing.Icon getIcon()
Returns the default icon


setRolloverIcon

public void setRolloverIcon(javax.swing.Icon icon)
Update the rollover icon property


getRolloverIcon

public javax.swing.Icon getRolloverIcon()
Returns the rollover icon


setPressedIcon

public void setPressedIcon(javax.swing.Icon icon)
Update the pressed icon property


getPressedIcon

public javax.swing.Icon getPressedIcon()
Returns the pressed icon


setDisabledIcon

public void setDisabledIcon(javax.swing.Icon icon)
Update the disabled icon property


getDisabledIcon

public javax.swing.Icon getDisabledIcon()
Returns the disabled icon


setRollover

public void setRollover(boolean isRollover)
Update the rollover state


setEnabled

public void setEnabled(boolean isEnabled)
Update the enabled state


setVisible

public void setVisible(boolean isVisible)
Update the visible state


setPressed

public void setPressed(boolean isPressed)
Update the pressed state


isRollover

public boolean isRollover()
Returns the rollover state


isPressed

public boolean isPressed()
Returns the pressed state


isEnabled

public boolean isEnabled()
Returns the enabled state


isVisible

public boolean isVisible()
Returns the visible state


paintIcon

public 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...)

Specified by:
paintIcon in interface javax.swing.Icon

getIconWidth

public int getIconWidth()
Specified by:
getIconWidth in interface javax.swing.Icon

getIconHeight

public int getIconHeight()
Specified by:
getIconHeight in interface javax.swing.Icon

fireAction

public void fireAction(java.awt.event.ActionEvent e)
triggers the associated action


getTooltipText

public java.lang.String getTooltipText()

setTooltipText

public void setTooltipText(java.lang.String tooltip)

propertyChange

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

Specified by:
propertyChange in interface java.beans.PropertyChangeListener


© Copyright 2004-2007 VLSolutions. All Rights Reserved.
www.vlsolutions.com : Java Components - Smart Client Applications