com.taursys.swing
Class MComboBoxModel

java.lang.Object
  extended byjavax.swing.AbstractListModel
      extended bycom.taursys.swing.MComboBoxModel
All Implemented Interfaces:
javax.swing.ComboBoxModel, javax.swing.ListModel, java.io.Serializable

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

MComboBoxModel is a ComboBoxModel for use with an MComboBox.

Version:
2.0
Author:
Marty Phelan
See Also:
Serialized Form

Field Summary
 
Fields inherited from class javax.swing.AbstractListModel
listenerList
 
Constructor Summary
MComboBoxModel()
          Constructs a new model with an empty option list.
MComboBoxModel(java.lang.Object[] items)
          Constructs a new model with the given items as the option list.
 
Method Summary
 void addEnableListener(EnableListener l)
          Adds the given listener to the list that is notified each time the enabled state changes.
protected  void fireEnableChange(EnableEvent e)
          Notify the listeners that the enabled state has changed.
 java.lang.Object getElementAt(int index)
          Get the item from the list at the given index.
 java.lang.String getListPropertyName()
          Get the property name in the ListValueHolder which will provide the selection value.
 java.lang.String[] getListPropertyNames()
          Get the property names in the ListValueHolder which will provide the selection values.
 ListValueHolder getListValueHolder()
          Get the valueHolder with the list of options for this component.
 java.lang.String getNullDisplay()
          Returns text to display in list for a null value.
 java.lang.String getPropertyName()
          Get the property name in the ValueHolder which will store the selection.
 java.lang.String[] getPropertyNames()
          Get the property names in the ValueHolder which will store the selection.
 java.lang.Object getSelectedItem()
          Get the selected item in the list.
 int getSize()
          Get the current size of the list.
 ValueHolder getValueHolder()
          Get the ValueHolder which will store the selection
 boolean isNullAllowed()
          Returns indicator that a null value is a valid selection.
 void removeEnableListener(EnableListener l)
          Removes the given listener from the list that is notified each time the enabled state changes.
 void setListPropertyName(java.lang.String listPropertyName)
          Set the property name in the ListValueHolder which will provide the selection value.
 void setListPropertyNames(java.lang.String[] listPropertyNames)
          Set the property names in the ListValueHolder which will provide the selection values.
 void setListValueHolder(ListValueHolder newListValueHolder)
          Set the valueHolder with the list of options for this component.
 void setNullAllowed(boolean nullAllowed)
          Sets indicator that a null value is a valid selection.
 void setNullDisplay(java.lang.String text)
          Sets text to display in list for a null value.
 void setPropertyName(java.lang.String propertyName)
          Set the property name in the ValueHolder which will store the selection.
 void setPropertyNames(java.lang.String[] propertyNames)
          Set the property names in the ValueHolder which will store the selection.
 void setSelectedItem(java.lang.Object anItem)
          Set the selected item in the list.
 void setValueHolder(ValueHolder valueHolder)
          Set the ValueHolder which will store the selection
 
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

MComboBoxModel

public MComboBoxModel()
Constructs a new model with an empty option list.


MComboBoxModel

public MComboBoxModel(java.lang.Object[] items)
Constructs a new model with the given items as the option list.

Method Detail

setSelectedItem

public void setSelectedItem(java.lang.Object anItem)
Set the selected item in the list.

Specified by:
setSelectedItem in interface javax.swing.ComboBoxModel
Parameters:
anItem - the selected item in the list.

getSelectedItem

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

Specified by:
getSelectedItem in interface javax.swing.ComboBoxModel
Returns:
the selected item in the list.

getSize

public int getSize()
Get the current size of the list.

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

getElementAt

public java.lang.Object getElementAt(int index)
Get the item from the list at the given index.

Specified by:
getElementAt in interface javax.swing.ListModel
Parameters:
index - indicates which item to return.
Returns:
the item from the list at the given index.

setValueHolder

public void setValueHolder(ValueHolder valueHolder)
Set the ValueHolder which will store the selection

Parameters:
valueHolder - the ValueHolder which will store the selection

getValueHolder

public ValueHolder getValueHolder()
Get the ValueHolder which will store the selection

Returns:
the ValueHolder which will store the selection

setPropertyName

public void setPropertyName(java.lang.String propertyName)
Set the property name in the ValueHolder which will store the selection. This name must correspond with the listPropertyName.

Parameters:
propertyName - the property name in the ValueHolder which will store the selection.

getPropertyName

public java.lang.String getPropertyName()
Get the property name in the ValueHolder which will store the selection. This name must correspond with the listPropertyName.

Returns:
the property name in the ValueHolder which will store the selection.

setPropertyNames

public void setPropertyNames(java.lang.String[] propertyNames)
Set the property names in the ValueHolder which will store the selection. The selection can be associated with multiple properties in the value holder. These property names must correspond to the listPropertyNames.

Parameters:
propertyNames - the property names in the ValueHolder which will store the selection.

getPropertyNames

public java.lang.String[] getPropertyNames()
Get the property names in the ValueHolder which will store the selection. The selection can be associated with multiple properties in the value holder. These property names must correspond to the listPropertyNames.

Returns:
the property names in the ValueHolder which will store the selection.

setListValueHolder

public void setListValueHolder(ListValueHolder newListValueHolder)
Set the valueHolder with the list of options for this component.

Parameters:
newListValueHolder - the valueHolder with the list of options for this component.

getListValueHolder

public ListValueHolder getListValueHolder()
Get the valueHolder with the list of options for this component.

Returns:
the valueHolder with the list of options for this component.

setListPropertyName

public void setListPropertyName(java.lang.String listPropertyName)
Set the property name in the ListValueHolder which will provide the selection value. This name must correspond with the propertyName for the valueHolder.

Parameters:
listPropertyName - the property name in the ListValueHolder which will provide the selection value.

getListPropertyName

public java.lang.String getListPropertyName()
Get the property name in the ListValueHolder which will provide the selection value. This name must correspond with the propertyName for the valueHolder.

Returns:
the property name in the ListValueHolder which will provide the selection value.

setListPropertyNames

public void setListPropertyNames(java.lang.String[] listPropertyNames)
Set the property names in the ListValueHolder which will provide the selection values. These names must correspond with the propertyNames for the valueHolder.

Parameters:
listPropertyNames - the property names in the ListValueHolder which will provide the selection values.

getListPropertyNames

public java.lang.String[] getListPropertyNames()
Get the property names in the ListValueHolder which will provide the selection values. These names must correspond with the propertyNames for the valueHolder.

Returns:
the property names in the ListValueHolder which will provide the selection values.

setNullAllowed

public void setNullAllowed(boolean nullAllowed)
Sets indicator that a null value is a valid selection. Default is true.


isNullAllowed

public boolean isNullAllowed()
Returns indicator that a null value is a valid selection. Default is true.


setNullDisplay

public void setNullDisplay(java.lang.String text)
Sets text to display in list for a null value.


getNullDisplay

public java.lang.String getNullDisplay()
Returns text to display in list for a null value.


removeEnableListener

public void removeEnableListener(EnableListener l)
Removes the given listener from the list that is notified each time the enabled state changes. EnableEvents are generated whenever the contents of the ValueHolder change. They indicate whether or not a component can modify the current contents of the ValueHolder (not-null).

Parameters:
l - the EnableListener to remove from the notify list.

addEnableListener

public void addEnableListener(EnableListener l)
Adds the given listener to the list that is notified each time the enabled state changes. EnableEvents are generated whenever the contents of the ValueHolder change. They indicate whether or not a component can modify the current contents of the ValueHolder (not-null).

Parameters:
l - the EnableListener to add to the notify list.

fireEnableChange

protected void fireEnableChange(EnableEvent e)
Notify the listeners that the enabled state has changed. EnableEvents are generated whenever the contents of the ValueHolder change. They indicate whether or not a component can modify the current contents of the ValueHolder (not-null).

Parameters:
e - the EnableEvent to send to the listeners on the notify list.


Copyright © 2007 Martin T Phelan. All Rights Reserved.