?
=?iso-8859-1?q?J=FCrgen_Gerstacker?=
Hello,
I want to periodically update a Combobox due to changes in the OS
(available RS232 serial ports).
I started to fill the box every time the combobox becomes visible
setup_cbport.removeAllItems();
while () {
...
setup_cbport.addItem(portId.getName());
...
}
setup_cbport.setSelectedItem(port); // previously selected item
But when the box is being filled, an actionPerformed is fired
public void actionPerformed(ActionEvent e) {
if (e.getSource()==setup_cbport) {
Object obj=setup_cbport.getSelectedItem();
port=(String)obj; // new selection
}
and the previous selected item is overwritten.
I could compare the items in the box with the new items and
'add'/'remove' individually but this would complicated the code. I
would like a simple solution, e.g. to allow the new selection only when
the user changes the ComboBox, not when the 'actionPerformed' is issued
by the System.
Any ideas?
Juergen
I want to periodically update a Combobox due to changes in the OS
(available RS232 serial ports).
I started to fill the box every time the combobox becomes visible
setup_cbport.removeAllItems();
while () {
...
setup_cbport.addItem(portId.getName());
...
}
setup_cbport.setSelectedItem(port); // previously selected item
But when the box is being filled, an actionPerformed is fired
public void actionPerformed(ActionEvent e) {
if (e.getSource()==setup_cbport) {
Object obj=setup_cbport.getSelectedItem();
port=(String)obj; // new selection
}
and the previous selected item is overwritten.
I could compare the items in the box with the new items and
'add'/'remove' individually but this would complicated the code. I
would like a simple solution, e.g. to allow the new selection only when
the user changes the ComboBox, not when the 'actionPerformed' is issued
by the System.
Any ideas?
Juergen