Java Reference
In-Depth Information
we fill with a ComboBoxModel instance. A ComboBoxModel is the object
underlying the graphical combo box that holds the values that can be
accessed by position.
It may be confusing in the following discussion that objects in Java
Swing holding values for underlying graphical representations are
called “models.” We will nevertheless use this terminology,
because it is the one used by user interface programmers. We will,
however, be precise, when necessary, and specify the type of
graphical model we are talking about, such as ComboBoxModel
mentioned above or TableModel . All graphical “models” provide
access to the values (for example, the values of a drop-down list)
based on the position (or the rank) of the values.
We have created a small extension of a DefaultComboBoxModel
to retrieve the names of the selected persisted named object
classes. The NamedObjectComboModel extends the DefaultComboBox-
Model and allows the returning of the object name at a given posi-
tion but also the casting of this object as a NamedObject for further
program use.
1. protected void start(Connection iConnection) {
2.
mDmeConn iConnection;
3.
try {
4.
final NamedObject[] lPersistence
5.
mDmeConn.getNamedObjects(PersistenceOption.persistentObject);
6.
NamedObjectComboModel lComboModel
7.
new NamedObjectComboModel(lPersistence);
8.
mPersistentObjectsCombo.setModel(lComboModel);
9.
handlerUpdateTableContent();
10.
} catch (JDMException lExce) {
11.
throw new UnexpectedJDMException(lExce);
12.
}
13.}
In line 5, the call to getNamedObjects returns the types of named
objects persisted by this DME implementation. The JDM enumera-
tion PersistenceOption provides two values: persistentObject and
transientObject . In this example, we are only interested in persistent
objects.
The method handlerUpdateTableContent executed at line 9 in the
previous code obtains the GUI user-selected named object class, and
 
Search WWH ::




Custom Search