java - get JSlider's input and changes -
i need use jslider getting input live, meaning return input without pressing button. have piece of code slider:
jpanel panel = new jpanel(); jslider js = new jslider(jslider.vertical, 0, 20, 10); js.setmajortickspacing(2); js.setpaintticks(true); hashtable labeltable = new hashtable(); labeltable.put(new integer(js.getminimum()), new jlabel("x0")); labeltable.put(new integer((js.getminimum() + js.getmaximum()) / 2), new jlabel("x1")); labeltable.put(new integer(js.getmaximum()), new jlabel("x2")); js.setlabeltable(labeltable); js.setpaintlabels(true); panel.add(js); int result = joptionpane.showconfirmdialog(null, panel, "choose size", joptionpane.yes_option);
is possible so? thought using actionlistener didn't succeed.
it's possible, using changelistener, example
slider.addchangelistener(new changelistener() { @override public void statechanged(changeevent e) { jslider slider = (jslider) e.getsource(); int value = slider.getvalue(); ... } });
Comments
Post a Comment