1
for(int i = 0; i<total_lines; i+=3) {
    cnames[cindex] = currlist.get(i);
    cfactor[cindex] = currlist.get(i+1);
    csymbol[cindex] = currlist.get(i+2);
    //currdata.addElement(cnames[cindex]);
    combocurrency.addItem(cnames[cindex]);
    cindex++; 
}
combocurrency = new JComboBox<String>(cnames);

When the application first starts, the the cnames array loads string data from default file. But during runtime when i upload a new file, cnames values' are updated, but the combocurrency values remains the same in the application! How can i overwrite the combobox values by loading a new file during runtime?

Andrew Thompson
  • 168,117
  • 40
  • 217
  • 433
guts98
  • 11
  • 1

2 Answers2

1

Take advantage of the MVC pattern here and work with a model. You can use DefaultComboBoxModel or implement your own if you need. A good example is given here: Dynamically adding items to a JComboBox

The_Cute_Hedgehog
  • 1,280
  • 13
  • 22
0

Try to clear the combobox of all entries using removeAllItems() before adding cnames