I am fetching the data values from the database successfully. I have also stored them into a String[] array. I need to load the String array as the items of the
This is the demo for illustrating default combo box model
public class ComboPanel extends JPanel {
JComboBox jcbo;
// this is constructor
public ComboPanel(ArrayList items) {
jcbo = new JComboBox();
// getting exiting combo box model
DefaultComboBoxModel model = (DefaultComboBoxModel) jcbo.getModel();
// removing old data
model.removeAllElements();
for (String item : items) {
model.addElement(item);
}
// setting model with new data
jcbo.setModel(model);
// adding combobox to panel
this.add(jcbo);
}
}
I hope this will help little :)