我的JScrollBar 的value 为什么总比Maximum值小10
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
class Tests extends JPanel{
private JScrollBar sb;
public Tests() {
setLayout(new BorderLayout());
sb = new JScrollBar();
//sb.setMaximum(100);
//sb.setMinimum(0);
add(sb, BorderLayout.WEST);
sb.addAdjustmentListener(new AdjustmentListener() {
public void adjustmentValueChanged(AdjustmentEvent e) {
JScrollBar jsb = (JScrollBar)e.getAdjustable();
if(jsb.getValueIsAdjusting())
System.out.println("adjusting ...");
else
System.out.println(Integer.toString(e.getValue()));
}
});
}
}
class Test extends JFrame
{
public Test()
{
Container ctp=getContentPane();
ctp.setLayout(new BorderLayout());
ctp.add(new Tests(),"Center");
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});
}
public static void main (String args[])
{
Test mytest=new Test();
mytest.setVisible(true);
mytest.setSize(300,300);
}
}