JAPI 0.9.0
Yet another Java API
API Documentation

net.sf.japi.swing
Class DisposeAction

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by net.sf.japi.swing.DisposeAction
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action

public final class DisposeAction
extends AbstractAction

An Action implementation that disposes a window when activated. Usually, you'd put an instance of this class in an actionmap, eventually pointing an inputmap to it. Usage example:

  JDialog d = new JDialog();
  DisposeAction da = new DisposeAction(d);
  d.getRootPane().getActionMap().put("close", da);
  d.getRootPane().getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW).put(KeyStroke.getKeyStroke("ESCAPE"), "close");
 
The convenience method install(JDialog) will do exactly that for an existing JDialog.

Author:
Christian Hujer
See Also:
Serialized Form
Todo:
basically this is the same as using an ActionFactory with dispose as method, so why not use that?

Field Summary
 
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
 
Fields inherited from interface javax.swing.Action
ACCELERATOR_KEY, ACTION_COMMAND_KEY, DEFAULT, LONG_DESCRIPTION, MNEMONIC_KEY, NAME, SHORT_DESCRIPTION, SMALL_ICON
 
Constructor Summary
DisposeAction(Window window)
          Create a DisposeAction.
 
Method Summary
 void actionPerformed(ActionEvent e)
          Invoked when an action occurs.
protected  Object clone()
          Clones the abstract action.
static DisposeAction install(JDialog dialog)
          Install the DisposeAction to a JDialog for the ESCAPE key.
 
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, firePropertyChange, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DisposeAction

public DisposeAction(@NotNull
                     Window window)
Create a DisposeAction.

Parameters:
window - Window to be disposed when this action is activated
Method Detail

install

public static DisposeAction install(@NotNull
                                    JDialog dialog)
Install the DisposeAction to a JDialog for the ESCAPE key. For most users of this method, the return value is irrelevant and can be ignored.

Parameters:
dialog - JDialog to install to
Returns:
the created DisposeAction

actionPerformed

public void actionPerformed(@NotNull
                            ActionEvent e)
Invoked when an action occurs.


clone

protected Object clone()
                throws CloneNotSupportedException
Clones the abstract action. This gives the clone its own copy of the key/value list, which is not handled for you by Object.clone().

Overrides:
clone in class AbstractAction
Returns:
a clone of this instance.
Throws:
CloneNotSupportedException - if the object's class does not support the Cloneable interface. Subclasses that override the clone method can also throw this exception to indicate that an instance cannot be cloned.
See Also:
Cloneable

JAPI
Yet another Java API
API Documentation

© 2005-2006 Christian Hujer. All rights reserved. See copyright