I'm trying to write a nice GUI in Swing that uses the proper Model-Delegate pattern as much as possible. I have a JComboBox that when changed, needs to update the model with the new data. To get the currently selected item, I am using:
fooCombo.addItemListener(new ItemListener() {
public void itemStateChanged(final ItemEvent arg0) {
fooChangedHandler((Foo) fooModel.getSelectedItem());
}
});
Which returns what the data was changed to as a nice Object. However, I can't find a way to find out the old value, so I don't know which object needs to be changed. Any ideas here?