java - Updating jLabel based on jSpinner -
right have jframe spinner has numbers. storing value of spinner this
int value = (integer) jspinner1.getvalue();
and outputting jlabel this
jlabel5.settext("counter = " + value );
i wondering if there way update jlabel every time number changed on spinner?
add changelistener , set label there.
jlabel l = ...; jspinner spinner = ...; spinner.addchangelistener(new changelistener() { public void statechanged(changeevent e) { l.settext("counter = " + spinner.getvalue()); } }
Comments
Post a Comment