I have a Java program with a model and a GUI. On my Frame (that implements Observer
) I have put a jcombobox with a list of registration from my model (that extends Observable
).
When I click on a button add registration the list in my model changed. And than I do
setChanged();
notifyObservers();
In my update method I want to make change the values of the jcombobox. I tried with a repaint()
or something like that, but my combobox doesn't change. I am sure I go to my update method, but I don't know how I have to change the jcombobox.
Can someone help
Your update()
implementation should obtain a reference to the combo's model and either set the selected item or add a new item, as warranted. A PropertyChangeEvent
, illustrated here, may be an alternative, as it can include both old and new values.