edu.cmu.hcii.calo.view.IconToggleButton Class Reference

List of all members.

Detailed Description

A simple transparency-aware toggle button that uses icons for its normal, mouseover, and pressed states in both selected and unselected modes.

Author:
Brian Ellis


Icons

The following icons are stored because JToggleButton is only capable of keeping track of a single pressed icon, whereas we need two: one for when the button is selected, and one for when it is not.

Icon pressedIcon
 The icon that should be used for this button when it is pressed, but not selected.
Icon pressedSelectedIcon
 The icon that should be used for this button when it is both pressed and selected.
 IconToggleButton (ImageIcon icon, ImageIcon selectedIcon)
 Constructs an icon toggle button, initially unselected, with no action.
 IconToggleButton (ImageIcon icon, ImageIcon pressedIcon, ImageIcon selectedIcon)
 Constructs an icon toggle button, initially unselected, with no action.
 IconToggleButton (ImageIcon icon, ImageIcon rolloverIcon, ImageIcon pressedIcon, ImageIcon selectedIcon)
 Constructs an icon toggle button, initially unselected, with no action.
 IconToggleButton (ImageIcon icon, ImageIcon rolloverIcon, ImageIcon pressedIcon, ImageIcon selectedIcon, ImageIcon selectedRolloverIcon, ImageIcon selectedPressedIcon)
 Constructs an icon toggle button, initially unselected, with no action.
 IconToggleButton (ImageIcon icon, ImageIcon rolloverIcon, ImageIcon pressedIcon, ImageIcon selectedIcon, ImageIcon selectedRolloverIcon, ImageIcon selectedPressedIcon, Action a)
 Constructs an icon toggle button, initially unselected, with the given action.
 IconToggleButton (ImageIcon icon)
 Constructs an icon toggle button, initially unselected, with no action.
Dimension getPreferredSize ()
 Returns the preferred size of this button.
Icon getPressedSelectedIcon ()
 Returns the pressed selected icon for the button.
Icon getPressedUnselectedIcon ()
 Returns the pressed unselected icon for the button.
void setPressedSelectedIcon (Icon pressedSelectedIcon)
 Sets the pressed selected icon for the button.
void setPressedUnselectedIcon (Icon pressedIcon)
 Sets the pressed unselected icon for the button.
void setSelectedToolTipText (String selectedToolTipText)
 Sets the text that should be shown on the tooltip for this button when it is selected.
void setUnselectedToolTipText (String unselectedToolTipText)
 Sets the text that should be shown on the tooltip for this button when it is selected.
String getSelectedToolTipText ()
 Returns the text that will be shown on the tooltip for this button when it is selected.
String getUnselectedToolTipText ()
 Returns the text that will be shown on the tooltip for this button when it is not selected.
void fireStateChanged ()
 Fires the state changed event for this button.
void setup (ImageIcon icon, ImageIcon rolloverIcon, ImageIcon pressedIcon, ImageIcon selectedIcon, ImageIcon rolloverSelectedIcon, ImageIcon pressedSelectedIcon)
 Sets up the visual appearance of this view.

Private Attributes

String unselectedToolTipText
 The text that should be shown in the tooltip for this button when it is unselected.
String selectedToolTipText
 The text that should be shown in the tooltip for this button when it is selected.


Constructor & Destructor Documentation

edu.cmu.hcii.calo.view.IconToggleButton.IconToggleButton ( ImageIcon  icon,
ImageIcon  selectedIcon 
)

Constructs an icon toggle button, initially unselected, with no action.

The button has a normal icon for its unselected state, and a normal icon for its selected state. The button will generate icons for its rollover and pressed icons using the unselected icon when unselected, and using its selected icon when selected.

Parameters:
icon the icon to use when the button is not selected
selectedIcon the icon to use when the button is selected

edu.cmu.hcii.calo.view.IconToggleButton.IconToggleButton ( ImageIcon  icon,
ImageIcon  pressedIcon,
ImageIcon  selectedIcon 
)

Constructs an icon toggle button, initially unselected, with no action.

The button has a normal icon for its unselected state, a normal icon for its selected state, and a pressed icon that is used in either state. The button will generate mouseover states using its unselected icon when unselected, and its selected icon when selected.

Parameters:
icon the icon to use when the button is not selected
selectedIcon the icon to use when the button is selected
pressedIcon the icon to use when the button is pressed and either selected or unselected

edu.cmu.hcii.calo.view.IconToggleButton.IconToggleButton ( ImageIcon  icon,
ImageIcon  rolloverIcon,
ImageIcon  pressedIcon,
ImageIcon  selectedIcon 
)

Constructs an icon toggle button, initially unselected, with no action.

The button has a normal, rollover, and pressed icon for its unselected state, and a normal icon for its selected state. The button will use the unselected state rollover and pressed icons even when in the selected state.

Parameters:
icon the icon to use when the button is unselected
rolloverIcon the icon to use when the button is in its mouseover state, whether selected or not
pressedIcon the icon to use when the button is pressed, whether selected or not
selectedIcon the icon to use when the button is selected

edu.cmu.hcii.calo.view.IconToggleButton.IconToggleButton ( ImageIcon  icon,
ImageIcon  rolloverIcon,
ImageIcon  pressedIcon,
ImageIcon  selectedIcon,
ImageIcon  selectedRolloverIcon,
ImageIcon  selectedPressedIcon 
)

Constructs an icon toggle button, initially unselected, with no action.

The button has a normal, rollover, and pressed icon for both of its states (selected and unselected).

Note:
You can pass null for any of these arguments except icon. The button will use the normal icon to intelligently generate states for any whose icons are null.
Parameters:
icon the normal icon
rolloverIcon the mouseover icon, or null to automatically generate one
pressedIcon the pressed icon, or null to automatically generate one
selectedIcon the selected icon, or null to automatically generate one
selectedRolloverIcon the selected mouseover icon, or null to automatically generate one
selectedPressedIcon the selected pressed icon, or null to automatically generate one

edu.cmu.hcii.calo.view.IconToggleButton.IconToggleButton ( ImageIcon  icon,
ImageIcon  rolloverIcon,
ImageIcon  pressedIcon,
ImageIcon  selectedIcon,
ImageIcon  selectedRolloverIcon,
ImageIcon  selectedPressedIcon,
Action  a 
)

Constructs an icon toggle button, initially unselected, with the given action.

The button has a normal, rollover, and pressed icon for both of its states (selected and unselected).

Note:
You can pass null for any of the icon arguments except icon. The button will use the normal icon to intelligently generate states for any whose icons are null.
Parameters:
icon the normal icon
rolloverIcon the mouseover icon, or null to automatically generate one
pressedIcon the pressed icon, or null to automatically generate one
selectedIcon the selected icon, or null to automatically generate one
selectedRolloverIcon the selected mouseover icon, or null to automatically generate one
selectedPressedIcon the selected pressed icon, or null to automatically generate one
a the Action to set

edu.cmu.hcii.calo.view.IconToggleButton.IconToggleButton ( ImageIcon  icon  ) 

Constructs an icon toggle button, initially unselected, with no action.

The button has a normal icon for its unselected state. The button will generate icons for all other states using this icon.

Parameters:
icon the icon to use when the button is not selected


Member Function Documentation

Dimension edu.cmu.hcii.calo.view.IconToggleButton.getPreferredSize (  ) 

Returns the preferred size of this button.

It is always the size of the icon, unless its preferred size has been explicitly set, in which case that value is returned instead.

Icon edu.cmu.hcii.calo.view.IconToggleButton.getPressedSelectedIcon (  ) 

Returns the pressed selected icon for the button.

Returns:
the pressed selected icon

Icon edu.cmu.hcii.calo.view.IconToggleButton.getPressedUnselectedIcon (  ) 

Returns the pressed unselected icon for the button.

Use this instead of AbstractButton.getPressedIcon() to ensure that you always get the unselected state (getPressedIcon() will return whichever icon corresponds to the current selection state of the button).

Returns:
the pressed selected icon

void edu.cmu.hcii.calo.view.IconToggleButton.setPressedSelectedIcon ( Icon  pressedSelectedIcon  ) 

Sets the pressed selected icon for the button.

Parameters:
pressedSelectedIcon the pressed selected icon

void edu.cmu.hcii.calo.view.IconToggleButton.setPressedUnselectedIcon ( Icon  pressedIcon  ) 

Sets the pressed unselected icon for the button.

Use this instead of AbstractButton.setPressedIcon() to avoid having your icon overwritten when the selected state changes.

Parameters:
pressedIcon the pressed icon

void edu.cmu.hcii.calo.view.IconToggleButton.setSelectedToolTipText ( String  selectedToolTipText  ) 

Sets the text that should be shown on the tooltip for this button when it is selected.

Parameters:
selectedToolTipText the selected tooltip text

void edu.cmu.hcii.calo.view.IconToggleButton.setUnselectedToolTipText ( String  unselectedToolTipText  ) 

Sets the text that should be shown on the tooltip for this button when it is selected.

Parameters:
unselectedToolTipText the unselected tooltip text

void edu.cmu.hcii.calo.view.IconToggleButton.fireStateChanged (  )  [protected]

Fires the state changed event for this button.

Overridden to also set the pressed icon and tooltip text correctly.

See also:
javax.swing.AbstractButton.fireStateChanged()

String edu.cmu.hcii.calo.view.IconToggleButton.getSelectedToolTipText (  ) 

Returns the text that will be shown on the tooltip for this button when it is selected.

Returns:
the selected tooltip text

String edu.cmu.hcii.calo.view.IconToggleButton.getUnselectedToolTipText (  ) 

Returns the text that will be shown on the tooltip for this button when it is not selected.

Use this instead of JComponent.getTooltipText() to ensure that you always get the unselected tooltip text (getTooltipText() will return the text of whatever tooltip would be shown if the mouse were to hover over the control right now).

Returns:
the unselected tooltip text

void edu.cmu.hcii.calo.view.IconToggleButton.setup ( ImageIcon  icon,
ImageIcon  rolloverIcon,
ImageIcon  pressedIcon,
ImageIcon  selectedIcon,
ImageIcon  rolloverSelectedIcon,
ImageIcon  pressedSelectedIcon 
) [private]

Sets up the visual appearance of this view.

Parameters:
icon the normal icon
rolloverIcon the mouseover icon, or null to automatically generate one
pressedIcon the pressed icon, or null to automatically generate one
selectedIcon the selected icon, or null to automatically generate one
rolloverSelectedIcon the selected mouseover icon, or null to automatically generate one
pressedSelectedIcon the selected pressed icon, or null to automatically generate one


Member Data Documentation

String edu.cmu.hcii.calo.view.IconToggleButton.unselectedToolTipText [private]

The text that should be shown in the tooltip for this button when it is unselected.

String edu.cmu.hcii.calo.view.IconToggleButton.selectedToolTipText [private]

The text that should be shown in the tooltip for this button when it is selected.

Icon edu.cmu.hcii.calo.view.IconToggleButton.pressedIcon [private]

The icon that should be used for this button when it is pressed, but not selected.

Icon edu.cmu.hcii.calo.view.IconToggleButton.pressedSelectedIcon [private]

The icon that should be used for this button when it is both pressed and selected.


The documentation for this class was generated from the following file:
Generated on Mon Aug 13 15:06:22 2007 for CALO by  doxygen 1.5.2