borland Packages Class Hierarchy dbswing Package
java.lang.Object +----com.borland.dbswing.DBListDataBinder
Constructors Properties Methods
Implements DBDataBinder, AccessListener, ColumnAware, DataChangeListener, DataSetAware, Designable, NavigationListener, PropertyChangeListener, Serializable, EventListener, ListSelectionListener
DBListDataBinder
maps a JList's
selected value to a DataSet
Column
value. More generally, DBListDataBinder
can map any selected value obtained from a ListModel
to a DataSet
value. In particular, DBListDataBinder
can be used to make a JList
write its currently selected value to a DataSet
, and to update its currently selected value when the DataSet
value changes.
There are two ways to use a DBListDataBinder
to make a list data-aware. The easier way is to set the JList
property to a JList
or subclass of JList
. You can also make any component using a ListModel
and ListSelectionModel
data-aware by setting DBListDataBinder's
listModel
and listSelectionModel
properties (or by adding DBListDataBinder
as a ListSelectionListener
to the component). If you take the second approach, you are responsible for opening the DataSet
.
In either case, you must set DBListDataBinder's
dataSet
and columName
properties to indicate the DataSet
and Column
from which the list value is to be read and to which it is to be written.
In addition to writing a value to a DataSet
when a list value is selected, DBListDataBinder
ensures that the selected list value indicates the current value of the DataSet
Column
to which it is attached. When the list is using a DBListModel
as its data model, DBListDataBinder
uses DataSet
methods to quickly find the matching value. Otherwise, the list's data model is searched sequentially until the first match is found. When the value in the DataSet
does not match a value in the list, DBListDataBinder
clears, by default, the list selection so no value is selected in the list. You can, however, set the unknownDataValueMode
property to specify alternative behavior.
JList jList = new JList(new String [] { "First", "Second", "Third" }); DBListDataBinder DBListDataBinder = new DBListDataBinder(); // when a value is selected from the list, it is written to the // "base" column of the DataSet DataSet DBListDataBinder.setJList(jList); DBListDataBinder.setDataSet(DataSet); DBListDataBinder.setColumnName("base");
public DBListDataBinder()Creates a
DBListDataBinder
. Calls the null
constructor of its superclass.
public DBListDataBinder(JList jList)Creates a
DBListDataBinder
with a specified list. Calls the null
constructor of its superclass.
jList
JList
that appears in the list.
public String getColumnName() public void setColumnName(String columnName)Returns and sets the column name of the
DataSet
from which values are read and to which values are written.
public DataSet getDataSet() public void setDataSet(DataSet dataSet)Returns and sets the
DataSet
from which values are read and to which values are written.
public JList getJList() public void setJList(JList jList)Returns and sets the
JList
the component is attached to. By setting the JList
property, you make the specified JList
data-aware as DBListDataBinder
maps the JList's
selected value to a DataSet
Column
value.
If you set the JList
property, DBListDataBinder
also binds the background
, foreground
, and font
properties from those defined on Column
columName
(if defined), unless already explicitly set on the JList
itself.
public ListModel getListModel() public void setListModel(ListModel listModel)Returns and sets the
ListModel
from which DBListDataBinder
maps a selected value to a DataSet
value.
public ListSelectionModel getListSelectionModel() public void setListSelectionModel(ListSelectionModel listSelectionModel)Returns and sets the
ListSelectionModel
from which DBListDataBinder
maps a selected value to a DataSet
value.
DBListDataBinder
assigns a single value only to a DataSet
Column
, and always uses the ListSelectionModel's
first selected value (ListSelectionModel.getMinSelectionIndex()
) as the currently selected value.
Note that there is always an implicit assumption that the ListSelectionModel's
indices are bound by the size of the ListModel
, even though neither model has a reference to the other. If you specify a ListSelectionModel
and ListModel
individually instead of setting the JList
property, be sure both models are working on the same model data.
public int getUnknownDataValueMode() public void setUnknownDataValueMode(int mode)Returns and sets the policy for setting the list selection when synchronizing a button with its
DataSet
value when the value can't be found in the list. The possible values are:
DataSet
value cannot be found in the list.
JList
property if the DataSet
value can not be found in the list.
DataSet
value if it does not match any value in the list, and clears the current list selection.