k***@gmail.com
2012-12-06 15:07:30 UTC
Hello Kinds Sirs,
I need a simple runnable example of a swing application that has a GUI with a jcombobox filled with a long list of name/value objects (eg 3000 employee names and numbers). There is also a worker process that reads in a record from a file/database, and then updates the gui jcombo box so that the employee item is "selected".
I was able to write something using java map and employee objects to set the selected item in the jcombo box, but if I invoke setSelectedItem in the worker thread, I get odd results/delays.
See below snippets... how should the worker thread pass the employee object back to the gui for it to setSelectedItem?
....
empBuffer= new Employee(id, lastName );
map.put(empBuffer.getId()+"",empBuffer );
model.addAll(map.values());
Collections.sort(model);
myComboBox1.setModel(new javax.swing.DefaultComboBoxModel(model));
....
emp = (Employee) map.get(myData.getEmployeeNum());
myComboBox1.setSelectedItem(emp);
I need a simple runnable example of a swing application that has a GUI with a jcombobox filled with a long list of name/value objects (eg 3000 employee names and numbers). There is also a worker process that reads in a record from a file/database, and then updates the gui jcombo box so that the employee item is "selected".
I was able to write something using java map and employee objects to set the selected item in the jcombo box, but if I invoke setSelectedItem in the worker thread, I get odd results/delays.
See below snippets... how should the worker thread pass the employee object back to the gui for it to setSelectedItem?
....
empBuffer= new Employee(id, lastName );
map.put(empBuffer.getId()+"",empBuffer );
model.addAll(map.values());
Collections.sort(model);
myComboBox1.setModel(new javax.swing.DefaultComboBoxModel(model));
....
emp = (Employee) map.get(myData.getEmployeeNum());
myComboBox1.setSelectedItem(emp);