I am playing around with common Swing components in java, and is struggling to figure out how to update JSlider.getValue().
Do I need to add a changelistener and an if Loop to check whether or not JSlider.getValueIsAdjusting() and then return the updated value?
How would one do this? Here is my code:
public static void main(String[] args){
Slider gui = new Slider();
}
JSlider slide = new JSlider(0, 100);
public Slider(){
super("Swing Slider");
setSize(300,200);
setDefaultCloseOperation(EXIT_ON_CLOSE);
add(pnl);
setVisible(true);
slide.setMajorTickSpacing(10);
slide.setMinorTickSpacing(5);
slide.setPaintTicks(true);
slide.setPaintLabels(true);
slide.setToolTipText("The value is: " + slide.getValue());
pnl.add(slide);
}
For example I was able to get the initial value of the slider(which is 50),
but when I adjust the slider, the value displayed is still 50, how do i update this?