Java Swing BoundedRangeModel get from JSlider
import java.awt.BorderLayout; import javax.swing.BoundedRangeModel; import javax.swing.JFrame; import javax.swing.JSlider; import javax.swing.event.ChangeEvent; import javax.swing.event.ChangeListener; public class Main extends JFrame { public Main() { JSlider slider = new JSlider(); BoundedRangeModel model = slider.getModel(); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); getContentPane().add(slider, BorderLayout.CENTER); model.addChangeListener(new ChangeListener() { public void stateChanged(ChangeEvent e) { System.out.println("Value: " + model.getValue()); }//ww w. j a va 2s . c om }); pack(); setVisible(true); } public static void main(String arg[]) { new Main(); } }