Help coderanch get a
new server
by contributing to the fundraiser
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

JComboBox popup refresh in a JApplet

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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!
 
reply
    Bookmark Topic Watch Topic
  • New Topic