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

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -