swing - java jspinner change listener trigger -
i have 2 comboboxes , spinner, work this: if selected item of first combo changed, second combo keeps selected item re-calls spinner (the spinner linked second box). problem can't trigger statechange listener of spinner when this.
here code forcing second box reselect last item when first 1 changed (nothing wrong here, works fine):
string orientare = (string) orientarecombobox.getselecteditem(); orientarecombobox.setselecteditem(orientare); this code second box actionlistener:
public void actionperformed(actionevent e) { jcombobox combo = (jcombobox) e.getsource(); string value = combo.getselecteditem().tostring(); if (value.equalsignorecase("oblica")) { unghispinner.setenabled(true); double unghi = (double) unghispinner.getvalue(); unghispinner.setvalue(new double(unghi)); } } and spinner's listener:
public void statechanged(changeevent e) { if (unghispinner.isenabled()) { // } } i not know command should use unghispinner trigger listener, because setvalue() can't it.
i don't see changing value of jspinner in code above. appears set spinner's value same value held previously, , shouldn't trigger listener. trigger change listener fire must change state of observed entity.
Comments
Post a Comment