Class ListAction

java.lang.Object
javax.swing.AbstractAction
de.stefanreiser.swing.misc.ListAction
All Implemented Interfaces:
java.awt.event.ActionListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.swing.Action

public abstract class ListAction
extends javax.swing.AbstractAction
Eine Action zur Verwendung mit JList.

Die Action wird ausgeführt, wenn in der zugeordneten JList ein Doppelklick oder ein Tastendruck (standardmäßig "Enter") auftritt.

Beispiel:


    ListAction listAction = new ListAction() {
        @Override public void actionPerformed(ActionEvent e) {
           // DO SOMETHING
        }};
    listAction.attachToJList(someJList);   // attaches Action to "someJList"
    listAction.attachToJList(otherJList);  // removes Action from "someJList"
    listAction.attachToJList(null);        // removes Action from "otherJList"

 

Source: https://tips4java.wordpress.com/2008/10/14/list-action/, http://www.camick.com/java/source/ListAction.java.

"You are free to use and/or modify any or all code posted on the Java Tips Weblog without restriction. A credit in the code comments would be nice, but not in any way mandatory." ( https://tips4java.wordpress.com/about/)

Author:
Rob Camick, Stefan Reiser (s.reiser@tu-braunschweig.de)
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
    ListAction()  
    ListAction​(javax.swing.KeyStroke keyStroke)  
  • Method Summary

    Modifier and Type Method Description
    abstract void actionPerformed​(java.awt.event.ActionEvent e)  
    void attachToJList​(javax.swing.JList list)
    Attach to list.

    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
  • Constructor Details

    • ListAction

      public ListAction()
    • ListAction

      public ListAction​(javax.swing.KeyStroke keyStroke)
      Parameters:
      keyStroke -
  • Method Details

    • attachToJList

      public void attachToJList​(javax.swing.JList list)
      Attach to list. If already attached to some other JList, remove from there.
      Parameters:
      list - Attach to this JList. If null then remove from current list if any.
    • actionPerformed

      public abstract void actionPerformed​(java.awt.event.ActionEvent e)