- 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
此类提供JFCAction接口的默认实现。 此处定义了标准行为,如Action对象属性(图标,文本和已启用)的get和set方法。 开发人员只需要对此抽象类进行子类化并定义actionPerformed方法。警告:此类的序列化对象与以后的Swing版本不兼容。 当前的序列化支持适用于运行相同版本Swing的应用程序之间的短期存储或RMI。 从1.4开始,
java.beans软件包中添加了对所有JavaBeansjava.beans长期存储的支持。 请参阅XMLEncoder。- 从以下版本开始:
- 1.2
- 另请参见:
-
Action, Serialized Form
-
-
字段汇总
字段 变量和类型 字段 描述 protected SwingPropertyChangeSupportchangeSupport如果已注册任何PropertyChangeListeners,则changeSupport字段描述它们。protected booleanenabled指定是否启用操作; 默认值为true。-
Fields declared in interface javax.swing.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
-
-
构造方法摘要
构造方法 构造器 描述 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)支持报告绑定的属性更改。Object[]getKeys()返回的数组ObjectS的是其值已针对该组按键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)设置是否启用Action。-
声明方法的类 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
如果已注册任何PropertyChangeListeners,则changeSupport字段描述它们。
-
-
构造方法详细信息
-
AbstractAction
public AbstractAction()
创建一个Action。
-
AbstractAction
public AbstractAction(String name)
创建具有指定名称的Action。- 参数
-
name- 该行动的名称(Action.NAME); 值null被忽略
-
-
方法详细信息
-
getValue
public Object getValue(String key)
获取与指定键关联的Object。- Specified by:
-
getValue,界面Action - 参数
-
key- 包含指定的key的字符串 - 结果
-
使用此密钥存储的绑定
Object; 如果没有钥匙,则返回null - 另请参见:
-
Action.getValue(java.lang.String)
-
putValue
public void putValue(String key, Object newValue)
设置与指定键关联的Value。- Specified by:
-
putValue在界面Action - 参数
-
key- 标识存储对象的String -
newValue- 使用此密钥存储的Object - 另请参见:
-
Action.putValue(java.lang.String, java.lang.Object)
-
isEnabled
public boolean isEnabled()
如果启用了操作,则返回true。- Specified by:
-
isEnabled在界面Action - 结果
- 如果操作已启用,则为true,否则为false
- 另请参见:
-
Action.isEnabled()
-
setEnabled
public void setEnabled(boolean newValue)
设置是否启用Action。 默认值为true。- Specified by:
-
setEnabled在界面Action - 参数
-
newValue-true启用此操作,false禁用它 - 另请参见:
-
Action.setEnabled(boolean)
-
getKeys
public Object[] getKeys()
返回的数组ObjectS的是其值已针对该组按键AbstractAction,或null如果没有键具有设定的值。- 结果
-
一组关键对象,如果没有键设置了值,
null - 从以下版本开始:
- 1.3
-
firePropertyChange
protected void firePropertyChange(String propertyName, Object oldValue, Object newValue)
支持报告绑定的属性更改。 当绑定属性发生更改时,可以调用此方法,并将相应的PropertyChangeEvent发送到任何已注册的PropertyChangeListeners。- 参数
-
propertyName- 已更改的属性的名称 -
oldValue- 属性的旧值 -
newValue- 该物业的新值
-
addPropertyChangeListener
public void addPropertyChangeListener(PropertyChangeListener listener)
将PropertyChangeListener添加到侦听器列表中。 监听器已注册所有属性。一个
PropertyChangeEvent将在响应被解雇到设置绑定属性,如setFont,setBackground,或setForeground。 请注意,如果当前组件从其容器继承其前景,背景或字体,则不会触发任何事件以响应继承属性的更改。- Specified by:
-
addPropertyChangeListener在接口Action - 参数
-
listener- 要添加的PropertyChangeListener - 另请参见:
-
Action.addPropertyChangeListener(java.beans.PropertyChangeListener)
-
removePropertyChangeListener
public void removePropertyChangeListener(PropertyChangeListener listener)
从侦听器列表中删除PropertyChangeListener。 这将删除为所有属性注册的PropertyChangeListener。- Specified by:
-
removePropertyChangeListener在界面Action - 参数
-
listener- 要删除的PropertyChangeListener - 另请参见:
-
Action.removePropertyChangeListener(java.beans.PropertyChangeListener)
-
getPropertyChangeListeners
public PropertyChangeListener[] getPropertyChangeListeners()
返回使用addPropertyChangeListener()添加到此AbstractAction的所有PropertyChangeListener的数组。- 结果
-
添加了所有
PropertyChangeListener或如果没有添加侦听器则为空数组 - 从以下版本开始:
- 1.4
-
clone
protected Object clone() throws CloneNotSupportedException
克隆抽象动作。 这为克隆提供了自己的键/值列表副本,Object.clone()无法为您处理。- 重写:
-
clone类Object - 结果
- 这个实例的克隆。
- 异常
-
CloneNotSupportedException- 如果对象的类不支持Cloneable接口。 覆盖clone方法的子类也可以抛出此异常以指示无法克隆实例。 - 另请参见:
-
Cloneable
-
-