com.jstatcom.component
Class CardPanelAction

java.lang.Object
  extended by javax.swing.AbstractAction
      extended by com.jstatcom.component.CardPanelAction
All Implemented Interfaces:
java.awt.event.ActionListener, java.io.Serializable, java.lang.Cloneable, java.util.EventListener, javax.swing.Action

public final class CardPanelAction
extends javax.swing.AbstractAction

An action for the task of showing a "card" component in a CardDisplayPanel.

The "card" component is only constructed when getComponent is called the first time. This way the component gets only created when the respective CardPanelAction is actually called. This may led to faster program start.

Author:
A. Benkwitz, M. Kraetzig
See Also:
CardDisplayPanel, Serialized Form

Field Summary
 
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
CardPanelAction(java.lang.String className, CardDisplayPanel parent, boolean enabled, java.lang.String name)
          Creates an action object that constructs a component on demand according to the arguments.
CardPanelAction(java.lang.String className, CardDisplayPanel parent, boolean enabled, java.lang.String name, javax.swing.Icon icon)
          Creates an action object that constructs a component on demand according to the arguments.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent arg1)
          Invoked when this action is called.
 javax.swing.JComponent getComponent()
          Gets the component defined via className in the constructor.
 
Methods inherited from class javax.swing.AbstractAction
addPropertyChangeListener, getKeys, getPropertyChangeListeners, getValue, isEnabled, putValue, removePropertyChangeListener, setEnabled
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CardPanelAction

public CardPanelAction(java.lang.String className,
                       CardDisplayPanel parent,
                       boolean enabled,
                       java.lang.String name)
Creates an action object that constructs a component on demand according to the arguments.

Parameters:
className - the string with the fully qualified class name of the component to construct when this action is called
parent - the parent panel
enabled - true if this action should be enabled
name - the name of this action
Throws:
java.lang.IllegalArgumentException - if (className == null) or if (parent == null)

CardPanelAction

public CardPanelAction(java.lang.String className,
                       CardDisplayPanel parent,
                       boolean enabled,
                       java.lang.String name,
                       javax.swing.Icon icon)
Creates an action object that constructs a component on demand according to the arguments.

Parameters:
className - the string with the fully qualified class name of the component to construct when this action is called
parent - the parent panel
enabled - true if this action should be enabled
name - the name of this action
icon - an icon to be displayed by components taking this AbstractAction as argument
Throws:
java.lang.IllegalArgumentException - if (className == null) or if (parent == null)
Method Detail

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent arg1)
Invoked when this action is called. Creates the respective component if it has not been created before and calls showCard of the parent CardDisplayPanel.

Parameters:
arg1 - argument is ignored and can be null

getComponent

public javax.swing.JComponent getComponent()
Gets the component defined via className in the constructor. If this method is called the first time, the component is first created.

Returns:
the component that has been defined via its class name in the constructor of this action, if the object construction failes, am empty JPanel with a message is returned