net.sf.jguiraffe.gui.platform.swing.builder.action
Class SwingCheckedItemController

java.lang.Object
  extended by net.sf.jguiraffe.gui.platform.swing.builder.action.SwingCheckedItemController
All Implemented Interfaces:
java.awt.event.ItemListener, java.beans.PropertyChangeListener, java.util.EventListener

 class SwingCheckedItemController
extends java.lang.Object
implements java.beans.PropertyChangeListener, java.awt.event.ItemListener

A helper class used for controlling the checked property of action controls.

Swing does not directly support the checked property for actions that is required by the action builder framework. Here it is possible to create checked menu items or toolbar buttons whose checked state is connected to the corresponding action. This class establishes such a connection. It registers itself as a PropertyChangeListener at a Swing action. Whenever the value of the checked property changes, the associated control is updated, too. The other direction is also supported: If the checked state of a control is changed, the action will be notified.

Version:
$Id: SwingCheckedItemController.java 26 2006-04-12 16:48:30Z oheger $
Author:
Oliver Heger

Constructor Summary
SwingCheckedItemController(SwingFormAction formAction, javax.swing.AbstractButton aButton)
          Creates a new instance of SwingCheckedItemController and initializes it.
 
Method Summary
 SwingFormAction getAction()
          Returns the wrapped Swing form action object.
 javax.swing.AbstractButton getButton()
          Returns the wrapped button component.
 void itemStateChanged(java.awt.event.ItemEvent event)
          Reacts on state changes of the associated button.
 void propertyChange(java.beans.PropertyChangeEvent event)
          Reacts on property change events of the associated action.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SwingCheckedItemController

public SwingCheckedItemController(SwingFormAction formAction,
                                  javax.swing.AbstractButton aButton)
Creates a new instance of SwingCheckedItemController and initializes it.

Parameters:
formAction - the action that must be associated with the control
aButton - the button controlled by this object
Method Detail

getButton

public javax.swing.AbstractButton getButton()
Returns the wrapped button component.

Returns:
the button

getAction

public SwingFormAction getAction()
Returns the wrapped Swing form action object.

Returns:
the action

propertyChange

public void propertyChange(java.beans.PropertyChangeEvent event)
Reacts on property change events of the associated action. If the checked property is affected, the button's state is updated.

Specified by:
propertyChange in interface java.beans.PropertyChangeListener
Parameters:
event - the change event

itemStateChanged

public void itemStateChanged(java.awt.event.ItemEvent event)
Reacts on state changes of the associated button. Ensures that the action will be updated if necessary.

Specified by:
itemStateChanged in interface java.awt.event.ItemListener
Parameters:
event - the item event


Copyright 2007 null. All Rights Reserved.