public abstract class AbstractAction extends Object implements Action, Cloneable, Serializable
Action接口的默认实现。
这里定义了标准行为,如Action对象属性(图标,文本和启用)的get和set方法。
开发人员只需要这个抽象类的子类,并定义actionPerformed方法。
警告:此类的序列化对象与将来的Swing版本不兼容。 当前的序列化支持适用于运行相同版本的Swing的应用程序之间的短期存储或RMI。 从1.4开始,对于所有JavaBeans的长期存储的支持已被添加到java.beans包中。 请参阅XMLEncoder 。
Action
| Modifier and Type | Field and Description |
|---|---|
protected SwingPropertyChangeSupport |
changeSupport
如果任何
PropertyChangeListeners已被注册,那么
changeSupport字段描述它们。
|
protected boolean |
enabled
指定是否启用动作;
默认值为true。
|
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, DISPLAYED_MNEMONIC_INDEX_KEY, LARGE_ICON_KEY, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SELECTED_KEY, SHORT_DESCRIPTION, SMALL_ICON| Constructor and Description |
|---|
AbstractAction()
创建一个
Action 。
|
AbstractAction(String name)
创建一个
Action具有指定名称。
|
AbstractAction(String name, Icon icon)
创建一个
Action具有指定名称和小图标。
|
| Modifier and Type | Method and Description |
|---|---|
void |
addPropertyChangeListener(PropertyChangeListener listener)
添加一个
PropertyChangeListener到监听器列表。
|
protected Object |
clone()
克隆抽象动作。
|
protected void |
firePropertyChange(String propertyName, Object oldValue, Object newValue)
支持报告绑定属性更改。
|
Object[] |
getKeys()
返回一个
Object s的数组,它们是为这个
AbstractAction设置了值的键,如果没有键设置值,则
null 。
|
PropertyChangeListener[] |
getPropertyChangeListeners()
返回使用addPropertyChangeListener()添加到此AbstractAction的所有
PropertyChangeListener的数组。
|
Object |
getValue(String key)
获取
Object与指定键关联。
|
boolean |
isEnabled()
如果启用该操作,则返回true。
|
void |
putValue(String key, Object newValue)
设置
Value与指定键关联。
|
void |
removePropertyChangeListener(PropertyChangeListener listener)
从侦听器列表中删除
PropertyChangeListener 。
|
void |
setEnabled(boolean newValue)
设置是否启用
Action 。
|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitactionPerformedprotected boolean enabled
protected SwingPropertyChangeSupport changeSupport
PropertyChangeListeners已被注册,那么
changeSupport字段描述它们。
public AbstractAction()
Action 。
public AbstractAction(String name)
Action具有指定名称。
name - 行动名称( Action.NAME );
值null被忽略
public Object getValue(String key)
Object与指定键关联。
getValue在界面
Action
key - 一个包含指定的字符串
key
Object存储的绑定Object ;
如果没有键,它将返回null
Action.getValue(java.lang.String)
public void putValue(String key, Object newValue)
Value与指定键关联。
putValue在界面
Action
key -所述
String标识所存储的对象
newValue -
Object存储使用这个键
Action.putValue(java.lang.String, java.lang.Object)
public boolean isEnabled()
isEnabled在界面
Action
Action.isEnabled()
public void setEnabled(boolean newValue)
Action 。
默认值为true 。
setEnabled在界面
Action
newValue -
true启用该操作,
false禁用它
Action.setEnabled(boolean)
public Object[] getKeys()
Object S的是其值已针对该组按键
AbstractAction ,或
null如果没有键具有设定的值。
null
protected void firePropertyChange(String propertyName, Object oldValue, Object newValue)
PropertyChangeEvent到任何已注册的PropertyChangeListeners 。
public void addPropertyChangeListener(PropertyChangeListener listener)
PropertyChangeListener添加到侦听器列表。
所有属性都注册了监听器。
一个PropertyChangeEvent将响应被炒到设置绑定属性,如setFont , setBackground ,或setForeground 。 请注意,如果当前组件从其容器继承其前台,背景或字体,则不会在继承的属性中更改时触发任何事件。
addPropertyChangeListener在界面
Action
listener - 要添加的
PropertyChangeListener
Action.addPropertyChangeListener(java.beans.PropertyChangeListener)
public void removePropertyChangeListener(PropertyChangeListener listener)
PropertyChangeListener 。
这消除了一个PropertyChangeListener已注册的所有属性。
removePropertyChangeListener在界面
Action
listener - 要删除的
PropertyChangeListener
Action.removePropertyChangeListener(java.beans.PropertyChangeListener)
public PropertyChangeListener[] getPropertyChangeListeners()
PropertyChangeListener的数组。
PropertyChangeListener添加了,或者如果没有添加侦听器,则为空数组
protected Object clone() throws CloneNotSupportedException
Object.clone()不会为您处理。
clone在类别
Object
CloneNotSupportedException - 如果对象的类不支持Cloneable接口。
覆盖clone方法的子类也可以抛出此异常以指示实例无法克隆。
Cloneable
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.