public abstract class AbstractAction extends Object implements Action, Cloneable, Serializable
Action接口的默认实现。喜欢和
Action对象属性设置方法的标准行为(图标、文字,并启用)的定义在这里。开发者只需要继承这个抽象类定义
actionPerformed方法。
警告:序列化该类的对象与以后的Swing版本不兼容。当前的序列化支持适用于短期贮藏或RMI运行相同Swing版本的应用程序之间。为1.4,为所有JavaBeans™长期存储的支持已被添加到java.beans包。请看XMLEncoder。
Action
| Modifier and Type | Field and Description |
|---|---|
protected SwingPropertyChangeSupport |
changeSupport
如果任何
PropertyChangeListeners已注册的
changeSupport场描述。
|
protected boolean |
enabled
指定是否启用动作;默认为真。
|
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()
返回
Objects是价值已为这个
AbstractAction键的数组,或
null如果没有键设置的值。
|
PropertyChangeListener[] |
getPropertyChangeListeners()
返回所有的
PropertyChangeListeners数组添加到这个摘要行动与addpropertychangelistener()。
|
Object |
getValue(String key)
获取具有指定键关联的
Object。
|
boolean |
isEnabled()
如果启用了动作,则返回真。
|
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;如果没有钥匙,它将返回
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()
Objects是价值已为这个
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()
PropertyChangeListeners数组添加到这个摘要行动与addpropertychangelistener()。
PropertyChangeListeners说如果没有听众已添加一个空数组
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.