所有类


javax.swing
类 AbstractAction

java.lang.Object
  继承者 javax.swing.AbstractAction
所有已实现的接口:
ActionListener, Serializable, Cloneable, EventListener, Action
直接已知子类:
BasicDesktopPaneUI.CloseAction, BasicDesktopPaneUI.MaximizeAction, BasicDesktopPaneUI.MinimizeAction, BasicDesktopPaneUI.NavigateAction, BasicDesktopPaneUI.OpenAction, BasicFileChooserUI.ApproveSelectionAction, BasicFileChooserUI.CancelSelectionAction, BasicFileChooserUI.ChangeToParentDirectoryAction, BasicFileChooserUI.GoHomeAction, BasicFileChooserUI.NewFolderAction, BasicFileChooserUI.UpdateAction, BasicInternalFrameTitlePane.CloseAction, BasicInternalFrameTitlePane.IconifyAction, BasicInternalFrameTitlePane.MaximizeAction, BasicInternalFrameTitlePane.MoveAction, BasicInternalFrameTitlePane.RestoreAction, BasicInternalFrameTitlePane.SizeAction, BasicSliderUI.ActionScroller, BasicTreeUI.TreeCancelEditingAction, BasicTreeUI.TreeHomeAction, BasicTreeUI.TreeIncrementAction, BasicTreeUI.TreePageAction, BasicTreeUI.TreeToggleAction, BasicTreeUI.TreeTraverseAction, MetalFileChooserUI.DirectoryComboBoxAction, TextAction

public abstract class AbstractAction
   
   
   
   
   
extends Object
implements Action, Cloneable, Serializable

此类提供 JFC Action 接口的默认实现。它定义了一些标准行为,比如 Action 对象属性(icon、text 和 enabled)的 get 和 set 方法。开发人员只需为此抽象类创建子类并定义 actionPerformed 方法即可。

警告:此类的已序列化对象与以后的 Swing 版本不兼容。当前序列化支持适用于短期存储,或适用于在运行相同 Swing 版本的应用程序之间进行 RMI(Remote Method Invocation,远程方法调用)。从 1.4 版本开始,已在 java.beans 包中添加了支持所有 JavaBeansTM 长期存储的功能。请参见 XMLEncoder

另请参见:
Action

字段摘要
protected  SwingPropertyChangeSupportchangeSupport
          如果已经注册了任意 PropertyChangeListener,则 changeSupport 字段负责描述它们。
protected  booleanenabled
          指定是否启用操作;默认值为 true。
 
从接口 javax.swing.Action 继承的字段
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SHORT_DESCRIPTION, SMALL_ICON
 
构造方法摘要
AbstractAction()
          用默认描述字符串和默认图标定义一个 Action 对象。
AbstractAction(String name)
          用指定描述字符串和默认图标定义一个 Action 对象。
AbstractAction(String name, Icon icon)
          用指定描述字符串和指定图标定义一个 Action 对象。
 
方法摘要
 voidaddPropertyChangeListener(PropertyChangeListener listener)
          向侦听器列表添加一个 PropertyChangeListener
protected  Objectclone()
          克隆抽象操作。
protected  voidfirePropertyChange(String propertyName, Object oldValue, Object newValue)
          支持报告 bound 属性的改变。
 Object[]getKeys()
          返回 Object 的数组,这些对象是一些已经为其设置此 AbstractAction 值的键,如果没有已经设置该值的键,则返回 null
 PropertyChangeListener[]getPropertyChangeListeners()
          返回使用 addPropertyChangeListener() 添加到此 AbstractAction 中的所有 PropertyChangeListener 组成的数组。
 ObjectgetValue(String key)
          获得与指定键关联的 Object
 booleanisEnabled()
          如果启用该操作,则返回 true。
 voidputValue(String key, Object newValue)
          设置与指定键关联的 Value
 voidremovePropertyChangeListener(PropertyChangeListener listener)
          从侦听器列表中移除一个 PropertyChangeListener
 voidsetEnabled(boolean newValue)
          启用或禁用该操作。
 
从类 java.lang.Object 继承的方法
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
从接口 java.awt.event.ActionListener 继承的方法
actionPerformed
 

字段详细信息

enabled

protected boolean enabled
指定是否启用操作;默认值为 true。


changeSupport

protected SwingPropertyChangeSupport changeSupport
如果已经注册了任意 PropertyChangeListener,则 changeSupport 字段负责描述它们。

构造方法详细信息

AbstractAction

public AbstractAction()
用默认描述字符串和默认图标定义一个 Action 对象。


AbstractAction

public AbstractAction(String name)
用指定描述字符串和默认图标定义一个 Action 对象。


AbstractAction

public AbstractAction(String name,
                      Icon icon)
用指定描述字符串和指定图标定义一个 Action 对象。

方法详细信息

getValue

public Object getValue(String key)
获得与指定键关联的 Object

指定者:
接口 Action 中的 getValue
参数:
key - 包含指定 key 的字符串
返回:
用此键存储的绑定 Object;如果没有键,则将返回 null
另请参见:
Action.getValue(java.lang.String)

putValue

public void putValue(String key,
                     Object newValue)
设置与指定键关联的 Value

指定者:
接口 Action 中的 putValue
参数:
key - 标识所存储对象的 String
newValue - 将使用此键存储的 Object
另请参见:
Action.putValue(java.lang.String, java.lang.Object)

isEnabled

public boolean isEnabled()
如果启用该操作,则返回 true。

指定者:
接口 Action 中的 isEnabled
返回:
如果启用该操作,则返回 true;否则返回 false
另请参见:
Action.isEnabled()

setEnabled

public void setEnabled(boolean newValue)
启用或禁用该操作。

指定者:
接口 Action 中的 setEnabled
参数:
newValue - 为 true 表示启用该操作,为 false 表示禁用该操作
另请参见:
Action.setEnabled(boolean)