|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
java.lang.Objectjavax.swing.AbstractAction
public abstract class AbstractAction
此类提供 JFC Action 接口的默认实现。它定义了一些标准行为,比如 Action 对象属性(icon、text 和 enabled)的 get 和 set 方法。开发人员只需为此抽象类创建子类并定义 actionPerformed 方法即可。
警告:此类的已序列化对象与以后的 Swing 版本不兼容。当前序列化支持适用于短期存储,或适用于在运行相同 Swing 版本的应用程序之间进行 RMI(Remote Method Invocation,远程方法调用)。从 1.4 版本开始,已在 java.beans 包中添加了支持所有 JavaBeansTM 长期存储的功能。请参见 XMLEncoder。
Action
| 字段摘要 | |
|---|---|
protected SwingPropertyChangeSupport |
changeSupport 如果已经注册了任意 PropertyChangeListener,则 changeSupport 字段负责描述它们。 |
protected boolean |
enabled 指定是否启用操作;默认值为 true。 |
| 从接口 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 对象。 |
|
| 方法摘要 | |
|---|---|
void |
addPropertyChangeListener(PropertyChangeListener listener) 向侦听器列表添加一个 PropertyChangeListener。 |
protected Object |
clone() 复制抽象操作。 |
protected void |
firePropertyChange(String propertyName, Object oldValue, Object newValue) 支持报告绑定 (bound) 属性的改变。 |
Object[] |
getKeys() 返回 Object 的数组,这些对象是一些已经为其设置此 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) 启用或禁用该操作。 |
| 从类 java.lang.Object 继承的方法 |
|---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| 从接口 java.awt.event.ActionListener 继承的方法 |
|---|
actionPerformed |
| 字段详细信息 |
|---|
protected boolean enabled
protected SwingPropertyChangeSupport changeSupport
PropertyChangeListener,则
changeSupport 字段负责描述它们。
| 构造方法详细信息 |
|---|
public AbstractAction()
Action 对象。
public AbstractAction(String name)
Action 对象。
public AbstractAction(String name,
Icon icon)
Action 对象。
| 方法详细信息 |
|---|
public Object getValue(String key)
Object。
Action 中的
getValue
key - 包含指定
key 的字符串
Object;如果没有键,则将返回
null
Action.getValue(java.lang.String)
public void putValue(String key,
Object newValue)
Value。
Action 中的
putValue
key - 标识所存储对象的
String
newValue - 将使用此键存储的
Object
Action.putValue(java.lang.String, java.lang.Object)
public boolean isEnabled()
Action 中的
isEnabled
Action.isEnabled()
public void setEnabled(boolean newValue)
Action 中的
setEnabled
newValue - 为 true 表示启用该操作,为 false 表示禁用该操作
Action.setEnabled(boolean)
public Object[] getKeys()
Object 的数组,这些对象是一些已经为其设置此
AbstractAction 值的键,如果没有已经设置该值的键,则返回
null。
null
protected void firePropertyChange(String propertyName,
Object oldValue,
Object newValue)
PropertyChangeListener 发送相应的
PropertyChangeEvent。
public void addPropertyChangeListener(PropertyChangeListener listener)
PropertyChangeListener。该侦听器是为所有属性注册的。
在响应对绑定属性(例如 setFont、setBackground 或 setForeground)的设置时,将触发一个 PropertyChangeEvent。注意,如果当前组件将继承其容器的前景、背景或字体,则在响应所继承属性中的更改时不会触发任何事件。
Action 中的
addPropertyChangeListener
listener - 要添加的
PropertyChangeListener
Action.addPropertyChangeListener(java.beans.PropertyChangeListener)
public void removePropertyChangeListener(PropertyChangeListener listener)
PropertyChangeListener。此方法移除了一个为所有属性注册的
PropertyChangeListener。
Action 中的
removePropertyChangeListener
listener - 要移除的
PropertyChangeListener
Action.removePropertyChangeListener(java.beans.PropertyChangeListener)
public PropertyChangeListener[] getPropertyChangeListeners()
PropertyChangeListener 组成的数组。
PropertyChangeListener,如果没有添加侦听器,则返回一个空数组
protected Object clone()
throws CloneNotSupportedException
Object.clone() 为您处理。
Object 中的
clone
CloneNotSupportedException - 如果对象的类不支持
Cloneable 接口,则重写
clone 方法的子类也会抛出此异常,以指示无法复制某个实例。
Cloneable
|
JavaTM Platform Standard Ed. 6 |
|||||||||
| 上一个类 下一个类 | 框架 无框架 | |||||||||
| 摘要: 嵌套 | 字段 | 构造方法 | 方法 | 详细信息: 字段 | 构造方法 | 方法 | |||||||||
版权所有 2007 Sun Microsystems, Inc. 保留所有权利。 请遵守许可证条款。另请参阅文档重新分发政策。