• Post Reply Bookmark Topic Watch Topic
  • New Topic

jdbc and swing  RSS feed

 
swati ksn
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am using a JComboBox in an Japplet.
In init() I am connecting to database & getting query result in resultset. I need to display ALL THE RECORDS one by one IN the JComboBox. How should I do it(painting?) & where in the program?
-Thanks.
 
Rene Liebmann
Ranch Hand
Posts: 196
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
the best way to deal with JComboBox is to use a model. In the most cases you can use the DefaultComboBoxModel.
DefaultComboBoxModel model = new DefaultComboBoxModel();
JComboBox cb = new JComboBox();
cb.setModel(model);
...
later you use this model to update the combobox
(addElement) It doesn't matter where this update is, the model will repaint the ComboBox, if neccessary.
Bye

Rene
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!