Problem with JSlider and its max value
Underneath I am posting the message that I posted at the java essentials forum, and since I was new I hadn't noticed this one. So maybe there could be a better answer here..
Here is the original:
I am creating a GUI and I am using 3 JSliders. I am implementing them all like the one that I am posting in the code below (which I have copied from my main project). My problem is that when I am running the program, the value can't be set more than 90 even though I have set the maximum value at 100. The getMaximum() method returns 100 whatsoever. Am I missing something here?
here is the code:
import java.awt.*;
import java.util.Hashtable;
import javax.swing.*;
publicclass Mainextends JFrame{
private JSlider slider;
public Main(){
super("Window");
Container container = getContentPane();
container.setLayout(new BorderLayout());
slider =new JSlider(JSlider.HORIZONTAL, 0, 100, 50);
Hashtable<Integer,JLabel> bandwidthLabels =new Hashtable<Integer,JLabel>();
bandwidthLabels.put(new Integer( 0 ),new JLabel("min") );
bandwidthLabels.put(new Integer( 100 ),new JLabel("max") );
slider.setLabelTable( bandwidthLabels );
slider.setMajorTickSpacing(10);
slider.setMinorTickSpacing(5);
slider.setExtent(10);
slider.setPaintTicks(true);
slider.setPaintLabels(true);
container.add(slider);
setResizable(false);
setSize(400, 200);
setVisible(true);
}
publicstaticvoid main(String[] args){
Main m =new Main();
m.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
Any help is appreciated. Thanks in advance!
Obviously the setExtent() method is my problem, which doesn't allow the knob to move past 90 (+10 = 100, the maximum). One practical solution I was offered was to put the maximum value at my current maximum + the extent and handle it that way from then on..
Any ideas on why is that happening?

