I am trying to populate a JComboBox in a JApplet.
The JApplet downloads from a webserver and takes a little time to retrieve some objects from a database, it is the names of these objects that I wish to place in the combo box menu.
I have tried two things:
1) Create the JComboBox empty, set the model to be DefaultCombBoxModel and when all the objects are retrieved, create a vector of all the object names, and add then to the combo box as follows:
Iterator objectsIt = addEm.iterator( );
while( objectsIt.hasNext( ) ){
String name = (String)objectsIt.next( );
( ( DefaultComboBoxModel )combo.getModel ( ) ).addElement( name );
itemCount = itemCount + 1;
}
However this results in the combobox popup remaining blank.
If I add a button to the display and wait until all the objects are loaded and then press the button, the result of the button using the same vector to populate the JComboBox (using the same above method) results in the items being displayed in the popup menu of the combo box!!???
2) Wait to create the combobox items until after the objects are retrieved and create the combobox with the vector of object names. I don't know if this works via the download because the comboboxes never appear after I add them to a Jpanel contained in the applet.
I am pretty sure it's a JApplet/Applet problem that I am having, if I run the applet as an application it works fine.
Help is appreciated!