org.xulux.guilayer.swing.models
Class DefaultComboModel

java.lang.Object
  extended by javax.swing.AbstractListModel
      extended by org.xulux.guilayer.swing.models.DefaultComboModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.ComboBoxModel, javax.swing.ListModel

public class DefaultComboModel
extends javax.swing.AbstractListModel
implements javax.swing.ComboBoxModel

The default combobox model.

Version:
$Id: DefaultComboModel.java,v 1.1 2005/12/18 12:58:21 mvdb Exp $
Author:
Martin van den Bemt
See Also:
Serialized Form

Nested Class Summary
 class DefaultComboModel.ComboShowable
          Holds all items in a list
 
Field Summary
 
Fields inherited from class javax.swing.AbstractListModel
listenerList
 
Constructor Summary
DefaultComboModel()
          don't do anything, since we don't have any data..
DefaultComboModel(java.util.List list, java.lang.String field, Combo combo)
          Constructor for DefaultComboModel.
 
Method Summary
 void destroy()
          Clean up combomodel (if at all needed)
 java.lang.Object getElementAt(int index)
          The comboshowable which is requested by the JCombo object.
protected  java.util.List getList()
           
protected  java.util.List getOriginal()
           
 java.lang.Object getRealSelectedValue()
           
 int getSelectedIndex()
           
 java.lang.Object getSelectedItem()
           
 int getSize()
           
protected  void initialize()
          Initialize the model and the data
 void setRealSelectedValue(java.lang.Object selectedItem)
          Set the real selected item (so not the comboshowable.
 void setSelectedItem(int index)
          Set the selected item to the specified index
 void setSelectedItem(java.lang.Object anItem)
          When using the arrow keys to select another item from the combo, we have to fire an event with the index0 and the index1 with the value -1.
 
Methods inherited from class javax.swing.AbstractListModel
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.ListModel
addListDataListener, removeListDataListener
 

Constructor Detail

DefaultComboModel

public DefaultComboModel()
don't do anything, since we don't have any data.. It will create an empty list however


DefaultComboModel

public DefaultComboModel(java.util.List list,
                         java.lang.String field,
                         Combo combo)
Constructor for DefaultComboModel.

Parameters:
list - the list with data
field - the field to use
combo - the combo used
Method Detail

setSelectedItem

public void setSelectedItem(java.lang.Object anItem)
When using the arrow keys to select another item from the combo, we have to fire an event with the index0 and the index1 with the value -1. This way you can actually see the selectedItem change on screen. If you don't fire this event, the selectedItem (onscreen!) will stay on the selected item on creation of the combo.

Specified by:
setSelectedItem in interface javax.swing.ComboBoxModel
See Also:
ComboBoxModel.setSelectedItem(Object)

setSelectedItem

public void setSelectedItem(int index)
Set the selected item to the specified index

Parameters:
index - the index to select

getSelectedItem

public java.lang.Object getSelectedItem()
Specified by:
getSelectedItem in interface javax.swing.ComboBoxModel
See Also:
ComboBoxModel.getSelectedItem()

getSize

public int getSize()
Specified by:
getSize in interface javax.swing.ListModel
See Also:
ListModel.getSize()

getElementAt

public java.lang.Object getElementAt(int index)
The comboshowable which is requested by the JCombo object.

Specified by:
getElementAt in interface javax.swing.ListModel
See Also:
ListModel.getElementAt(int)

getRealSelectedValue

public java.lang.Object getRealSelectedValue()
Returns:
the real selected value in the combo, so not a comboshowable

getSelectedIndex

public int getSelectedIndex()
Returns:
the selected index in the model If the selection is null, it will return -1

setRealSelectedValue

public void setRealSelectedValue(java.lang.Object selectedItem)
Set the real selected item (so not the comboshowable.

Parameters:
selectedItem - the real selected item

initialize

protected void initialize()
Initialize the model and the data


destroy

public void destroy()
Clean up combomodel (if at all needed)


getOriginal

protected java.util.List getOriginal()
Returns:
the original data

getList

protected java.util.List getList()
Returns:
the data in the combo


Copyright © 2002-2007 Martin van den Bemt. All Rights Reserved.