Package uk.ac.starlink.topcat

## Class TopcatWindowAction<W extends javax.swing.JFrame>

- java.lang.Object
- - javax.swing.AbstractAction
  - - uk.ac.starlink.topcat.BasicAction
    - - uk.ac.starlink.topcat.TopcatWindowAction<W>

- All Implemented Interfaces:
    `java.awt.event.ActionListener`, `java.io.Serializable`, `java.lang.Cloneable`, `java.util.EventListener`, `javax.swing.Action`, `TopcatToolAction`

      public class TopcatWindowAction<W extends javax.swing.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

    Constructors
    Constructor | Description
    --- | ---
    `TopcatWindowAction​(java.lang.String name, javax.swing.Icon icon, java.lang.String shortdesc, java.lang.Class<? extends W> winClazz)` | Constructor.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `void` | `actionPerformed​(java.awt.event.ActionEvent evt)` | Performs the action.
    `protected W` | `createWindow()` | Creates an instance of the window class used by this action.
    `void` | `setParent​(java.awt.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

      `accept, addPropertyChangeListener, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled`

- - ### Constructor Detail

    - #### TopcatWindowAction

          public TopcatWindowAction​(java.lang.String name,
                                    javax.swing.Icon icon,
                                    java.lang.String shortdesc,
                                    java.lang.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​(java.awt.event.ActionEvent evt)

      Performs the action. The default immplementation just calls `createWindow()` and sets it visible. This may be overridden.
      Specified by:
        `actionPerformed` in interface `java.awt.event.ActionListener`

    - #### setParent

          public void setParent​(java.awt.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