net.sf.jguiraffe.gui.platform.swing.builder.components
Class SwingComboBoxHandler

java.lang.Object
  extended by net.sf.jguiraffe.gui.platform.swing.builder.components.SwingComponentHandler
      extended by net.sf.jguiraffe.gui.platform.swing.builder.components.SwingListModelHandler
          extended by net.sf.jguiraffe.gui.platform.swing.builder.components.SwingComboBoxHandler
All Implemented Interfaces:
java.awt.event.ActionListener, java.util.EventListener, ListComponentHandler, ComponentHandler, SwingEventSource
Direct Known Subclasses:
SwingEditableComboBoxHandler

 class SwingComboBoxHandler
extends SwingListModelHandler
implements java.awt.event.ActionListener

A specific Swing component handler implementation that deals with combo boxes.

This class manages a JComboBox component, which is not editable. The specified ListModel is used to transform the combo box's selected index into a value object.

Version:
$Id: SwingComboBoxHandler.java 71 2007-06-16 20:47:48Z oheger $
Author:
Oliver Heger

Constructor Summary
SwingComboBoxHandler(javax.swing.JComboBox combo, ListModel m)
          Creates a new instance of SwingComboBoxHandler and initializes it.
 
Method Summary
 void actionPerformed(java.awt.event.ActionEvent event)
          Callback for action events.
 javax.swing.JComboBox getComboBox()
          Returns the managed combo box.
 java.lang.Object getData()
          Returns this component's data.
protected  void initComponentModel(SwingListModel model)
          Initializes the combo box with the given list model.
protected  void registerChangeListener()
          Registers this component handler as a change listener at the managed component.
 void setData(java.lang.Object data)
          Sets the data of this component.
protected  void unregisterChangeListener()
          Unregisters this component as change listener from the managed component.
 
Methods inherited from class net.sf.jguiraffe.gui.platform.swing.builder.components.SwingListModelHandler
addItem, createSwingListModel, getListModel, getType, removeItem
 
Methods inherited from class net.sf.jguiraffe.gui.platform.swing.builder.components.SwingComponentHandler
addActionListener, addChangeListener, addFocusListener, fireChangeEvent, getComponent, getJComponent, getOuterComponent, isEnabled, removeActionListener, removeChangeListener, removeFocusListener, setEnabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.jguiraffe.gui.forms.ComponentHandler
getComponent, getOuterComponent, isEnabled, setEnabled
 

Constructor Detail

SwingComboBoxHandler

public SwingComboBoxHandler(javax.swing.JComboBox combo,
                            ListModel m)
Creates a new instance of SwingComboBoxHandler and initializes it.

Parameters:
combo - the combo box
m - the list model for the combo box
Method Detail

getComboBox

public javax.swing.JComboBox getComboBox()
Returns the managed combo box.

Returns:
the managed combo box component

registerChangeListener

protected void registerChangeListener()
Registers this component handler as a change listener at the managed component. This implementation registers an action listener.

Overrides:
registerChangeListener in class SwingComponentHandler

unregisterChangeListener

protected void unregisterChangeListener()
Unregisters this component as change listener from the managed component.

Overrides:
unregisterChangeListener in class SwingComponentHandler
See Also:
SwingComponentHandler.registerChangeListener()

getData

public java.lang.Object getData()
Returns this component's data. Based on the selected index an object from the list model will be returned.

Specified by:
getData in interface ComponentHandler
Returns:
the component's data

setData

public void setData(java.lang.Object data)
Sets the data of this component.

Specified by:
setData in interface ComponentHandler
Parameters:
data - the new data (which should be an item of the list model)

actionPerformed

public void actionPerformed(java.awt.event.ActionEvent event)
Callback for action events. An action event indicates a change in the combobox's selection.

Specified by:
actionPerformed in interface java.awt.event.ActionListener
Parameters:
event - the event

initComponentModel

protected void initComponentModel(SwingListModel model)
Initializes the combo box with the given list model.

Specified by:
initComponentModel in class SwingListModelHandler
Parameters:
model - the list model


Copyright 2007 null. All Rights Reserved.