< prev index next >
src/java.desktop/share/classes/javax/swing/AbstractAction.java
Print this page
*** 36,58 ****
import java.security.AccessController;
import javax.swing.event.SwingPropertyChangeSupport;
import sun.security.action.GetPropertyAction;
/**
! * This class provides default implementations for the JFC <code>Action</code>
* interface. Standard behaviors like the get and set methods for
! * <code>Action</code> object properties (icon, text, and enabled) are defined
* here. The developer need only subclass this abstract class and
! * define the <code>actionPerformed</code> method.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans™
! * has been added to the <code>java.beans</code> package.
* Please see {@link java.beans.XMLEncoder}.
*
* @author Georges Saab
* @see Action
* @since 1.2
--- 36,58 ----
import java.security.AccessController;
import javax.swing.event.SwingPropertyChangeSupport;
import sun.security.action.GetPropertyAction;
/**
! * This class provides default implementations for the JFC {@code Action}
* interface. Standard behaviors like the get and set methods for
! * {@code Action} object properties (icon, text, and enabled) are defined
* here. The developer need only subclass this abstract class and
! * define the {@code actionPerformed} method.
* <p>
* <strong>Warning:</strong>
* Serialized objects of this class will not be compatible with
* future Swing releases. The current serialization support is
* appropriate for short term storage or RMI between applications running
* the same version of Swing. As of 1.4, support for long term storage
* of all JavaBeans™
! * has been added to the {@code java.beans} package.
* Please see {@link java.beans.XMLEncoder}.
*
* @author Georges Saab
* @see Action
* @since 1.2
*** 153,167 ****
this(name);
putValue(Action.SMALL_ICON, icon);
}
/**
! * Gets the <code>Object</code> associated with the specified key.
*
! * @param key a string containing the specified <code>key</code>
! * @return the binding <code>Object</code> stored with this key; if there
! * are no keys, it will return <code>null</code>
* @see Action#getValue
*/
public Object getValue(String key) {
if (key == "enabled") {
return enabled;
--- 153,167 ----
this(name);
putValue(Action.SMALL_ICON, icon);
}
/**
! * Gets the {@code Object} associated with the specified key.
*
! * @param key a string containing the specified {@code key}
! * @return the binding {@code Object} stored with this key; if there
! * are no keys, it will return {@code null}
* @see Action#getValue
*/
public Object getValue(String key) {
if (key == "enabled") {
return enabled;
*** 171,184 ****
}
return arrayTable.get(key);
}
/**
! * Sets the <code>Value</code> associated with the specified key.
*
! * @param key the <code>String</code> that identifies the stored object
! * @param newValue the <code>Object</code> to store using this key
* @see Action#putValue
*/
public void putValue(String key, Object newValue) {
Object oldValue = null;
if (key == "enabled") {
--- 171,184 ----
}
return arrayTable.get(key);
}
/**
! * Sets the {@code Value} associated with the specified key.
*
! * @param key the {@code String} that identifies the stored object
! * @param newValue the {@code Object} to store using this key
* @see Action#putValue
*/
public void putValue(String key, Object newValue) {
Object oldValue = null;
if (key == "enabled") {
*** 240,253 ****
}
}
/**
! * Returns an array of <code>Object</code>s which are keys for
! * which values have been set for this <code>AbstractAction</code>,
! * or <code>null</code> if no keys have values set.
! * @return an array of key objects, or <code>null</code> if no
* keys have values set
* @since 1.3
*/
public Object[] getKeys() {
if (arrayTable == null) {
--- 240,253 ----
}
}
/**
! * Returns an array of {@code Object}s which are keys for
! * which values have been set for this {@code AbstractAction},
! * or {@code null} if no keys have values set.
! * @return an array of key objects, or {@code null} if no
* keys have values set
* @since 1.3
*/
public Object[] getKeys() {
if (arrayTable == null) {
*** 257,276 ****
arrayTable.getKeys(keys);
return keys;
}
/**
! * If any <code>PropertyChangeListeners</code> have been registered, the
! * <code>changeSupport</code> field describes them.
*/
protected SwingPropertyChangeSupport changeSupport;
/**
* Supports reporting bound property changes. This method can be called
* when a bound property has changed and it will send the appropriate
! * <code>PropertyChangeEvent</code> to any registered
! * <code>PropertyChangeListeners</code>.
*
* @param propertyName the name of the property that has changed
* @param oldValue the old value of the property
* @param newValue the new value of the property
*/
--- 257,276 ----
arrayTable.getKeys(keys);
return keys;
}
/**
! * If any {@code PropertyChangeListeners} have been registered, the
! * {@code changeSupport} field describes them.
*/
protected SwingPropertyChangeSupport changeSupport;
/**
* Supports reporting bound property changes. This method can be called
* when a bound property has changed and it will send the appropriate
! * {@code PropertyChangeEvent} to any registered
! * {@code PropertyChangeListeners}.
*
* @param propertyName the name of the property that has changed
* @param oldValue the old value of the property
* @param newValue the new value of the property
*/
*** 282,302 ****
changeSupport.firePropertyChange(propertyName, oldValue, newValue);
}
/**
! * Adds a <code>PropertyChangeListener</code> to the listener list.
* The listener is registered for all properties.
* <p>
! * A <code>PropertyChangeEvent</code> will get fired in response to setting
! * a bound property, e.g. <code>setFont</code>, <code>setBackground</code>,
! * or <code>setForeground</code>.
* Note that if the current component is inheriting its foreground,
* background, or font from its container, then no event will be
* fired in response to a change in the inherited property.
*
! * @param listener The <code>PropertyChangeListener</code> to be added
*
* @see Action#addPropertyChangeListener
*/
public synchronized void addPropertyChangeListener(PropertyChangeListener listener) {
if (changeSupport == null) {
--- 282,302 ----
changeSupport.firePropertyChange(propertyName, oldValue, newValue);
}
/**
! * Adds a {@code PropertyChangeListener} to the listener list.
* The listener is registered for all properties.
* <p>
! * A {@code PropertyChangeEvent} will get fired in response to setting
! * a bound property, e.g. {@code setFont}, {@code setBackground},
! * or {@code setForeground}.
* Note that if the current component is inheriting its foreground,
* background, or font from its container, then no event will be
* fired in response to a change in the inherited property.
*
! * @param listener The {@code PropertyChangeListener} to be added
*
* @see Action#addPropertyChangeListener
*/
public synchronized void addPropertyChangeListener(PropertyChangeListener listener) {
if (changeSupport == null) {
*** 305,319 ****
changeSupport.addPropertyChangeListener(listener);
}
/**
! * Removes a <code>PropertyChangeListener</code> from the listener list.
! * This removes a <code>PropertyChangeListener</code> that was registered
* for all properties.
*
! * @param listener the <code>PropertyChangeListener</code> to be removed
*
* @see Action#removePropertyChangeListener
*/
public synchronized void removePropertyChangeListener(PropertyChangeListener listener) {
if (changeSupport == null) {
--- 305,319 ----
changeSupport.addPropertyChangeListener(listener);
}
/**
! * Removes a {@code PropertyChangeListener} from the listener list.
! * This removes a {@code PropertyChangeListener} that was registered
* for all properties.
*
! * @param listener the {@code PropertyChangeListener} to be removed
*
* @see Action#removePropertyChangeListener
*/
public synchronized void removePropertyChangeListener(PropertyChangeListener listener) {
if (changeSupport == null) {
*** 322,335 ****
changeSupport.removePropertyChangeListener(listener);
}
/**
! * Returns an array of all the <code>PropertyChangeListener</code>s added
* to this AbstractAction with addPropertyChangeListener().
*
! * @return all of the <code>PropertyChangeListener</code>s added or an empty
* array if no listeners have been added
* @since 1.4
*/
public synchronized PropertyChangeListener[] getPropertyChangeListeners() {
if (changeSupport == null) {
--- 322,335 ----
changeSupport.removePropertyChangeListener(listener);
}
/**
! * Returns an array of all the {@code PropertyChangeListener}s added
* to this AbstractAction with addPropertyChangeListener().
*
! * @return all of the {@code PropertyChangeListener}s added or an empty
* array if no listeners have been added
* @since 1.4
*/
public synchronized PropertyChangeListener[] getPropertyChangeListeners() {
if (changeSupport == null) {
*** 340,350 ****
/**
* Clones the abstract action. This gives the clone
* its own copy of the key/value list,
! * which is not handled for you by <code>Object.clone()</code>.
**/
protected Object clone() throws CloneNotSupportedException {
AbstractAction newAction = (AbstractAction)super.clone();
synchronized(this) {
--- 340,350 ----
/**
* Clones the abstract action. This gives the clone
* its own copy of the key/value list,
! * which is not handled for you by {@code Object.clone()}.
**/
protected Object clone() throws CloneNotSupportedException {
AbstractAction newAction = (AbstractAction)super.clone();
synchronized(this) {
< prev index next >