Package net.sf.freecol.client.gui.action
Class SelectableAction
- java.lang.Object
-
- javax.swing.AbstractAction
-
- net.sf.freecol.client.gui.action.FreeColAction
-
- net.sf.freecol.client.gui.action.MapboardAction
-
- net.sf.freecol.client.gui.action.SelectableAction
-
- All Implemented Interfaces:
java.awt.event.ActionListener
,java.io.Serializable
,java.lang.Cloneable
,java.util.EventListener
,javax.swing.Action
,ObjectWithId
,Option<FreeColAction>
- Direct Known Subclasses:
ChangeWindowedModeAction
,DisplayBordersAction
,DisplayFogOfWarAction
,DisplayGridAction
,DisplayTileTextAction
,MapControlsAction
public abstract class SelectableAction extends MapboardAction
An action for selecting one of several options.- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class net.sf.freecol.client.gui.action.FreeColAction
FreeColAction.InnerMenuKeyListener
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
id
private java.lang.String
optionId
protected boolean
selected
-
Fields inherited from class net.sf.freecol.client.gui.action.FreeColAction
ACTION_ID, BUTTON_DISABLED_IMAGE, BUTTON_IMAGE, BUTTON_PRESSED_IMAGE, BUTTON_ROLLOVER_IMAGE, freeColClient, logger, TAG
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
SelectableAction(FreeColClient freeColClient, java.lang.String id, java.lang.String optionId)
Creates this action.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
getOption()
Get the value of the underlying option.boolean
isSelected()
Gets whether the action is selected.void
setOption(boolean value)
Set the option value.void
setSelected(boolean b)
Sets whether the action is selected.protected boolean
shouldBeSelected()
Should this action be selected? Override this in subclasses.void
update()
Updates the "enabled"-status with the value returned byFreeColAction.shouldBeEnabled()
.-
Methods inherited from class net.sf.freecol.client.gui.action.MapboardAction
shouldBeEnabled
-
Methods inherited from class net.sf.freecol.client.gui.action.FreeColAction
addImageIcons, cloneOption, getAccelerator, getActionManager, getClientOptions, getConnectController, getEnabledBy, getFreeColClient, getGame, getGroup, getGUI, getId, getMap, getMenuKeyListener, getMnemonic, getName, getShortDescription, getValue, getXMLTagName, hasOrderButtons, igc, readFromXML, setAccelerator, setGroup, setMnemonic, setValue, toString, toXML, updateRegisteredImageIcons
-
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
-
-
-
-
Field Detail
-
id
public static final java.lang.String id
- See Also:
- Constant Field Values
-
optionId
private final java.lang.String optionId
-
selected
protected boolean selected
-
-
Constructor Detail
-
SelectableAction
protected SelectableAction(FreeColClient freeColClient, java.lang.String id, java.lang.String optionId)
Creates this action.- Parameters:
freeColClient
- TheFreeColClient
for the game.id
- The object identifier.optionId
- The identifier of a boolean client option.
-
-
Method Detail
-
getOption
public final boolean getOption()
Get the value of the underlying option.- Returns:
- The option value.
-
setOption
public final void setOption(boolean value)
Set the option value.- Parameters:
value
- The new boolean value.
-
isSelected
public final boolean isSelected()
Gets whether the action is selected.- Returns:
- True if this action is selected.
-
setSelected
public final void setSelected(boolean b)
Sets whether the action is selected.- Parameters:
b
- The new selection value.
-
shouldBeSelected
protected boolean shouldBeSelected()
Should this action be selected? Override this in subclasses.- Returns:
- True of this action should be selected.
-
update
public void update()
Updates the "enabled"-status with the value returned byFreeColAction.shouldBeEnabled()
.- Overrides:
update
in classFreeColAction
-
-