ActionListener
, Externalizable
, Serializable
, EventListener
, Action
, Presenter
, Presenter.Menu
, Presenter.Popup
, Presenter.Toolbar
, HelpCtx.Provider
public abstract class BooleanStateAction extends SystemAction implements Presenter.Menu, Presenter.Popup, Presenter.Toolbar
PROP_BOOLEAN_STATE
property.
The default value of the state is true
(on).
This action is not the most effective way to implement checkbox in a menu. Consider using more modern alternative: Actions.checkbox.
Presenter.Menu, Presenter.Popup, Presenter.Toolbar
Modifier and Type | Field | Description |
---|---|---|
static String |
PROP_BOOLEAN_STATE |
Name of property hold the state of the action.
|
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON
PROP_ENABLED, PROP_ICON
Constructor | Description |
---|---|
BooleanStateAction() |
Modifier and Type | Method | Description |
---|---|---|
void |
actionPerformed(ActionEvent ev) |
Actually perform the action.
|
boolean |
getBooleanState() |
Get the current state.
|
JMenuItem |
getMenuPresenter() |
Get a menu item that can present this action in a
JMenu . |
JMenuItem |
getPopupPresenter() |
Get a menu item that can present this action in a
JPopupMenu . |
Component |
getToolbarPresenter() |
Get a component that can present this action in a
JToolBar . |
protected void |
initialize() |
Initialize the action.
|
void |
setBooleanState(boolean value) |
Set the current state.
|
accept, addPropertyChangeListener, removePropertyChangeListener
clone, getClass, notify, notifyAll, toString, wait, wait, wait
addNotify, addPropertyChangeListener, equals, finalize, findObject, findObject, firePropertyChange, getLock, getProperty, hashCode, putProperty, putProperty, readExternal, removeNotify, removePropertyChangeListener, reset, writeExternal, writeReplace
clearSharedData, createPopupMenu, createToolbarPresenter, get, getHelpCtx, getIcon, getIcon, getName, getValue, iconResource, isEnabled, linkActions, putValue, setEnabled, setIcon
public static final String PROP_BOOLEAN_STATE
public JMenuItem getMenuPresenter()
Presenter.Menu
JMenu
.
If your menu content is dynamic in nature, consider using DynamicMenuContentgetMenuPresenter
in interface Presenter.Menu
public JMenuItem getPopupPresenter()
Presenter.Popup
JPopupMenu
.
If your menu content is dynamic in nature, consider using DynamicMenuContentgetPopupPresenter
in interface Presenter.Popup
public Component getToolbarPresenter()
Presenter.Toolbar
JToolBar
.getToolbarPresenter
in interface Presenter.Toolbar
public boolean getBooleanState()
true
if onpublic void setBooleanState(boolean value)
value
- true
to turn on, false
to turn offprotected void initialize()
SystemAction
initialize
in class SystemAction
public void actionPerformed(ActionEvent ev)
SystemAction
ActionListener.actionPerformed(java.awt.event.ActionEvent)
.
In some cases, the implementation may have an empty body, if the presenters handle the performing of the action in a different way than by calling this method.
Since 4.11, will be performed directly in the event thread.
actionPerformed
in interface ActionListener
actionPerformed
in class SystemAction
ev
- the event triggering the actionBuilt on April 24 2018. | Portions Copyright 1997-2018 Oracle. All rights reserved.