uk.ac.starlink.topcat
Class TopcatWindowAction<W extends JFrame>

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by uk.ac.starlink.topcat.BasicAction
          extended by uk.ac.starlink.topcat.TopcatWindowAction<W>
All Implemented Interfaces:
ActionListener, Serializable, Cloneable, EventListener, Action, TopcatToolAction

public class TopcatWindowAction<W extends JFrame>
extends BasicAction
implements TopcatToolAction

TopcatToolAction implementation that instantiates a window of a given class when invoked. The window will be instantiated via a constructor taking a single Component argument; such a constructor must therefore exist. This parent component is just used to position the window, it's permissible, though not encouraged, to just ignore that argument.

Since:
24 Jul 2013
Author:
Mark Taylor
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.AbstractAction
changeSupport, enabled
 
Fields inherited from interface 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
 
Constructor Summary
TopcatWindowAction(String name, Icon icon, String shortdesc, Class<? extends W> winClazz)
          Constructor.
 
Method Summary
 void actionPerformed(ActionEvent evt)
          Performs the action.
protected  W createWindow()
          Creates an instance of the window class used by this action.
 void setParent(Component parent)
          Sets the parent component to use for initialising windows created by this action.
 
Methods inherited from class uk.ac.starlink.topcat.BasicAction
getEventWindow
 
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, clone, 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
 
Methods inherited from interface javax.swing.Action
addPropertyChangeListener, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
 

Constructor Detail

TopcatWindowAction

public TopcatWindowAction(String name,
                          Icon icon,
                          String shortdesc,
                          Class<? extends W> winClazz)
Constructor.

Parameters:
name - action name
icon - action icon
shortdesc - action short description
winClazz - class of window to instantiate; must have a constructor that takes a java.awt.Component giving the window parent
Method Detail

createWindow

protected W createWindow()
Creates an instance of the window class used by this action.

Returns:
window initialised with parent component

actionPerformed

public void actionPerformed(ActionEvent evt)
Performs the action. The default immplementation just calls createWindow() and sets it visible. This may be overridden.

Specified by:
actionPerformed in interface ActionListener

setParent

public void setParent(Component parent)
Sets the parent component to use for initialising windows created by this action.

Specified by:
setParent in interface TopcatToolAction
Parameters:
parent - parent component


Copyright © 2003-2018 CCLRC: Council for the Central Laboratory of the Research Councils. All Rights Reserved.