Package uk.ac.starlink.topcat
Class ToggleButtonModel
java.lang.Object
javax.swing.DefaultButtonModel
javax.swing.JToggleButton.ToggleButtonModel
uk.ac.starlink.topcat.ToggleButtonModel
- All Implemented Interfaces:
ItemSelectable
,Serializable
,ButtonModel
- Direct Known Subclasses:
WindowToggle
Provides all information about a toggle button. This is not only
it's current on/off status (selection state in swing talk), but
also the button's name, tooltip etc. Swing doesn't provide a
model/action for this, so this class does it instead.
Factory methods are provided to create Swing components that use
this as their model.
- Since:
- 3 Nov 2005
- Author:
- Mark Taylor
- See Also:
-
Field Summary
Fields inherited from class javax.swing.DefaultButtonModel
actionCommand, ARMED, changeEvent, ENABLED, group, listenerList, mnemonic, PRESSED, ROLLOVER, SELECTED, stateMask
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionCreates and returns a normal button using this model.Creates and returns a check box using this model.Creates and returns a menu item using this model.createRadioButtons
(String name0, String name1) Creates and returns a pair of radio buttons using this model.Creates and returns a button suitable for use in a toolbar using this model.void
Returns the description (for tooltips etc) associated with this model.getIcon()
Returns the icon associated with this model.getText()
Returns the text label associated with this model.boolean
Returns the state of this model.void
setDescription
(String shortdesc) Sets the description (for tooltips etc) associated with this model.void
Sets the icon associated with this model.void
setSelected
(boolean state) Sets the state of this model.void
Sets the text label associated with this model.Methods inherited from class javax.swing.JToggleButton.ToggleButtonModel
setPressed
Methods inherited from class javax.swing.DefaultButtonModel
addActionListener, addChangeListener, addItemListener, fireItemStateChanged, fireStateChanged, getActionCommand, getActionListeners, getChangeListeners, getGroup, getItemListeners, getListeners, getMnemonic, getSelectedObjects, isArmed, isEnabled, isPressed, isRollover, removeActionListener, removeChangeListener, removeItemListener, setActionCommand, setArmed, setEnabled, setGroup, setMnemonic, setRollover
-
Constructor Details
-
ToggleButtonModel
Constructor.- Parameters:
text
- text to be used on buttons etcicon
- icon to be used on buttons etcshortdesc
- short description to be used for tool tips etc
-
-
Method Details
-
setText
Sets the text label associated with this model.- Parameters:
text
- button name
-
getText
Returns the text label associated with this model.- Returns:
- button name
-
setIcon
Sets the icon associated with this model.- Parameters:
icon
- button icon
-
getIcon
Returns the icon associated with this model.- Returns:
- button icon
-
setDescription
Sets the description (for tooltips etc) associated with this model.- Parameters:
shortdesc
- description
-
getDescription
Returns the description (for tooltips etc) associated with this model.- Returns:
- description
-
createButton
Creates and returns a normal button using this model.- Returns:
- button
-
createToolbarButton
Creates and returns a button suitable for use in a toolbar using this model. The button has no text.- Returns:
- button
-
createMenuItem
Creates and returns a menu item using this model.- Returns:
- checkbox menu item
-
createCheckBox
Creates and returns a check box using this model.- Returns:
- checkbox
-
createRadioButtons
Creates and returns a pair of radio buttons using this model. One unselects it, and the other selects it.- Parameters:
name0
- name of the Off controlname1
- name of the On control- Returns:
- array of (Off, On) controls
-
setSelected
public void setSelected(boolean state) Sets the state of this model.- Specified by:
setSelected
in interfaceButtonModel
- Overrides:
setSelected
in classJToggleButton.ToggleButtonModel
- Parameters:
state
- on/off status
-
isSelected
public boolean isSelected()Returns the state of this model.- Specified by:
isSelected
in interfaceButtonModel
- Overrides:
isSelected
in classJToggleButton.ToggleButtonModel
- Returns:
- on/off status
-
fireActionPerformed
- Overrides:
fireActionPerformed
in classDefaultButtonModel
-