• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

JComboBox popup refresh in a JApplet  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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!
 
Don't sweat petty things, or pet sweaty things. But cuddle this tiny ad:
how do I do my own kindle-like thing - without amazon
https://coderanch.com/t/711421/engineering/kindle-amazon
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!