Package uk.ac.starlink.topcat

# Class BasicAction

java.lang.Object
javax.swing.AbstractAction
uk.ac.starlink.topcat.BasicAction

All Implemented Interfaces:
  `ActionListener`, `Serializable`, `Cloneable`, `EventListener`, `Action`

Direct Known Subclasses:
  `GraphicsWindow.ExportAction`, `LayerControlAction`, `LinesWindow.RescaleAction`, `TopcatWindowAction`, `WindowAction`

public abstract class BasicAction extends AbstractAction
Convenience class extending AbstractAction.

Author:
  Mark Taylor (Starlink)
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
`BasicAction(String name, String descrip)`
Constructor without icon.
`BasicAction(String name, Icon icon, String descrip)`
Constructor with icon.

## Method Summary

Modifier and Type
Method
Description
`static BasicAction`
`create(String name, Icon icon, String descrip, Consumer<ActionEvent> perform)`
Convenience method to create an Action with a lambda to define the actionPerformed behaviour.
`Component`
`getEventWindow(ActionEvent evt)`
Returns the window from which this action was invoked.

### 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`

### Methods inherited from interface java.awt.event.ActionListener

`actionPerformed`

## Constructor Details

### BasicAction

public BasicAction(String name, String descrip)
Constructor without icon.

Parameters:
  `name` - action name (NAME property)
  `descrip` - action description (SHORT_DESCRIPTION property), used as tooltip text

### BasicAction

public BasicAction(String name, Icon icon, String descrip)
Constructor with icon.

Parameters:
  `name` - action name (NAME property)
  `icon` - action icon (SMALL_ICON property)
  `descrip` - action description (SHORT_DESCRIPTION property), used as tooltip text

## Method Details

### getEventWindow

public Component getEventWindow(ActionEvent evt)
Returns the window from which this action was invoked. This is currently the Frame in which the event originated.

Parameters:
  `evt` - event to check the window for
Returns:
  window in which evt originated if it can be determined - may be null

### create

public static BasicAction create(String name, Icon icon, String descrip, Consumer<ActionEvent> perform)
Convenience method to create an Action with a lambda to define the actionPerformed behaviour.

Parameters:
  `name` - action name (NAME property)
  `icon` - action icon (SMALL_ICON property)
  `descrip` - action description (SHORT_DESCRIPTION property), used as tooltip text
  `perform` - provides `actionPerformed` behaviour
Returns:
  new action