站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc 4.1.0

BooleanStateAction (NetBeans APIs) - NetBeans API Javadoc 4.1.0


org.openide.util.actions
Class BooleanStateAction

java.lang.Object
  extended byorg.openide.util.SharedClassObject
      extended byorg.openide.util.actions.SystemAction
          extended byorg.openide.util.actions.BooleanStateAction
All Implemented Interfaces:
Action, ActionListener, EventListener, Externalizable, HelpCtx.Provider, Presenter, Presenter.Menu, Presenter.Popup, Presenter.Toolbar, Serializable

public abstract class BooleanStateAction
extends SystemAction
implements Presenter.Menu, Presenter.Popup, Presenter.Toolbar

An action that can be toggled on or off. The actual "performing" of the action is the toggle itself, so this action should be used by listening to the PROP_BOOLEAN_STATE property.

The default value of the state is true (on).

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class org.openide.util.actions.Presenter
Presenter.Menu, Presenter.Popup, Presenter.Toolbar
 
Field Summary
static String PROP_BOOLEAN_STATE
          Name of property hold the state of the action.
 
Fields inherited from class org.openide.util.actions.SystemAction
PROP_ENABLED, PROP_ICON
 
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SHORT_DESCRIPTION, SMALL_ICON
 
Constructor Summary
BooleanStateAction()
           
 
Method Summary
 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.
 
Methods inherited from class org.openide.util.actions.SystemAction
clearSharedData, createPopupMenu, createToolbarPresenter, get, getHelpCtx, getIcon, getIcon, getName, getValue, iconResource, isEnabled, linkActions, putValue, setEnabled, setIcon
 
Methods inherited from class org.openide.util.SharedClassObject
addNotify, addPropertyChangeListener, equals, finalize, findObject, findObject, firePropertyChange, getLock, getProperty, hashCode, putProperty, putProperty, readExternal, removeNotify, removePropertyChangeListener, reset, writeExternal, writeReplace
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.Action
addPropertyChangeListener, removePropertyChangeListener
 

Field Detail

PROP_BOOLEAN_STATE

public static final String PROP_BOOLEAN_STATE
Name of property hold the state of the action.

See Also:
Constant Field Values
Constructor Detail

BooleanStateAction

public BooleanStateAction()
Method Detail

getMenuPresenter

public JMenuItem getMenuPresenter()
Description copied from interface: Presenter.Menu
Get a menu item that can present this action in a JMenu.

Specified by:
getMenuPresenter in interface Presenter.Menu
Returns:
the representation for this action

getPopupPresenter

public JMenuItem getPopupPresenter()
Description copied from interface: Presenter.Popup
Get a menu item that can present this action in a JPopupMenu.

Specified by:
getPopupPresenter in interface Presenter.Popup
Returns:
the representation for this action

getToolbarPresenter

public Component getToolbarPresenter()
Description copied from interface: Presenter.Toolbar
Get a component that can present this action in a JToolBar.

Specified by:
getToolbarPresenter in interface Presenter.Toolbar
Returns:
the representation for this action

getBooleanState

public boolean getBooleanState()
Get the current state.

Returns:
true if on

setBooleanState

public void setBooleanState(boolean value)
Set the current state. Fires a change event, which should be used to affect other components when its state is toggled.

Parameters:
value - true to turn on, false to turn off

initialize

protected void initialize()
Description copied from class: SystemAction
Initialize the action. The default implementation just enabled it.

Overrides:
initialize in class SystemAction

actionPerformed

public void actionPerformed(ActionEvent ev)
Description copied from class: SystemAction
Actually perform the action. Specified in 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.

Specified by:
actionPerformed in interface ActionListener
Specified by:
actionPerformed in class SystemAction
Parameters:
ev - the event triggering the action


Built on May 4 2005.  |  Portions Copyright 1997-2005 Sun Microsystems, Inc. All rights reserved.