gov.nasa.gsfc.drl.rtstps.library
Class AComboModel

java.lang.Object
  extended by gov.nasa.gsfc.drl.rtstps.library.AComboModel
All Implemented Interfaces:
javax.swing.ComboBoxModel, javax.swing.ListModel

public class AComboModel
extends java.lang.Object
implements javax.swing.ComboBoxModel

This class promotes the model AListModel (a JList model) to a combo box model. It uses the decorator pattern to enhance AListModel. Typically you construct an AListModel first. The code looks like this: AListModel alm = new AListModel(); AComboModel acm = new AComboModel(alm); JComboBox combo = new JComboBox(acm);


Field Summary
protected  AListModel listModel
          The underlying list model.
private  java.lang.Object selected
           
 
Constructor Summary
AComboModel(AListModel alm)
          Construct an AComboModel object from an AListModel object.
 
Method Summary
 void add(java.lang.String obj)
          Append an object to the model but only if it is not a duplicate (via isEquals).
 void addListDataListener(javax.swing.event.ListDataListener l)
          Add a ListDataListener to the model.
 boolean contains(java.lang.Object obj)
          Determine if the model contains the object via the equals method.
 java.lang.Object getElementAt(int index)
          Get the object at list index index
 java.lang.Object getSelectedItem()
          Get the selected item object.
 int getSize()
          Get the number of items in the list.
 void removeListDataListener(javax.swing.event.ListDataListener l)
          Remove a ListDataListener.
 void setSelectedItem(java.lang.Object obj)
          Set the selected object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

listModel

protected AListModel listModel
The underlying list model.


selected

private java.lang.Object selected
Constructor Detail

AComboModel

public AComboModel(AListModel alm)
Construct an AComboModel object from an AListModel object.

Parameters:
alm - An AListModel object.
Method Detail

addListDataListener

public void addListDataListener(javax.swing.event.ListDataListener l)
Add a ListDataListener to the model.

Specified by:
addListDataListener in interface javax.swing.ListModel

removeListDataListener

public void removeListDataListener(javax.swing.event.ListDataListener l)
Remove a ListDataListener.

Specified by:
removeListDataListener in interface javax.swing.ListModel

getSize

public int getSize()
Get the number of items in the list.

Specified by:
getSize in interface javax.swing.ListModel
Returns:
the list size

getElementAt

public java.lang.Object getElementAt(int index)
Get the object at list index index

Specified by:
getElementAt in interface javax.swing.ListModel
Returns:
the object at the specified index

contains

public boolean contains(java.lang.Object obj)
Determine if the model contains the object via the equals method.


add

public void add(java.lang.String obj)
Append an object to the model but only if it is not a duplicate (via isEquals). It ignores duplicates. Property change listeners will receive an event message if the state changes from empty to non-empty.


setSelectedItem

public void setSelectedItem(java.lang.Object obj)
Set the selected object. If the object is null, it shows a blank entry in the combo box input cell.

Specified by:
setSelectedItem in interface javax.swing.ComboBoxModel
Parameters:
obj - The selected item

getSelectedItem

public java.lang.Object getSelectedItem()
Get the selected item object.

Specified by:
getSelectedItem in interface javax.swing.ComboBoxModel
Returns:
Returns the selected item. It returns null if there is no selected object.