edu.iastate.metnet.model
Class JDBCComboModel

java.lang.Object
  extended by javax.swing.AbstractListModel
      extended by edu.iastate.metnet.model.JDBCComboModel
All Implemented Interfaces:
java.io.Serializable, javax.swing.ComboBoxModel, javax.swing.ListModel

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

general adpater between JDBC and JComboxModel

Author:
Jie Li
See Also:
Serialized Form

Field Summary
(package private)  java.util.Vector rows
           
(package private)  java.lang.Object selectedObject
          Creates a new instance of JDBCComboModel
 
Fields inherited from class javax.swing.AbstractListModel
listenerList
 
Constructor Summary
JDBCComboModel(java.sql.ResultSet rs)
          construct the table model from the column of the result set.
JDBCComboModel(java.sql.ResultSet rs, int index)
          construct the table model from the column of the result set
JDBCComboModel(java.sql.ResultSet rs, java.lang.String columnName)
          construct the table model from the column of the result set
 
Method Summary
 void appendResultSet(java.sql.ResultSet rs)
           
 void appendResultSet(java.sql.ResultSet rs, int index)
          append another row data from another result set
 void appendResultSet(java.sql.ResultSet rs, java.lang.String columnName)
          append another row data from another result set
 java.lang.Object getElementAt(int param)
          get the value object in the list model
 java.lang.Object getSelectedItem()
          get the selected value object
 int getSize()
          get the size of the combobox model
 void setSelectedItem(java.lang.Object anItem)
          set the selected item to the specified value object
 
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
 

Field Detail

selectedObject

java.lang.Object selectedObject
Creates a new instance of JDBCComboModel


rows

java.util.Vector rows
Constructor Detail

JDBCComboModel

public JDBCComboModel(java.sql.ResultSet rs,
                      int index)
construct the table model from the column of the result set

Parameters:
rs - the result set used by the model
index - the column index of the result set

JDBCComboModel

public JDBCComboModel(java.sql.ResultSet rs,
                      java.lang.String columnName)
construct the table model from the column of the result set

Parameters:
rs - the result set used by the model
columnName - the name of the column

JDBCComboModel

public JDBCComboModel(java.sql.ResultSet rs)
construct the table model from the column of the result set. The model uses the first column of the result set in default

Parameters:
rs - the result set used by the model
Method Detail

appendResultSet

public void appendResultSet(java.sql.ResultSet rs,
                            int index)
append another row data from another result set

Parameters:
rs - the result set
index - the row index

appendResultSet

public void appendResultSet(java.sql.ResultSet rs,
                            java.lang.String columnName)
append another row data from another result set

Parameters:
rs - the result set to be used
columnName - the name of the column

appendResultSet

public void appendResultSet(java.sql.ResultSet rs)

getSize

public int getSize()
get the size of the combobox model

Specified by:
getSize in interface javax.swing.ListModel
Returns:
the size of the combobox model

getElementAt

public java.lang.Object getElementAt(int param)
get the value object in the list model

Specified by:
getElementAt in interface javax.swing.ListModel
Parameters:
param - the index of the object in the list model
Returns:
the value object

getSelectedItem

public java.lang.Object getSelectedItem()
get the selected value object

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

setSelectedItem

public void setSelectedItem(java.lang.Object anItem)
set the selected item to the specified value object

Specified by:
setSelectedItem in interface javax.swing.ComboBoxModel
Parameters:
anItem - the value object to be selected