java JSlider的使用
JSlider jsl = new JSlider(10,200); jsl.setMajorTickSpacing(20);//设置主刻度标记的间隔 jsl.setMinorTickSpacing(5);//设置次刻度标记的间隔 jsl.setPaintTicks(true);//绘制标签 jsl.setPaintLabels(true);//绘制数字 frame.add(jsl); jsl.addChangeListener(new ChangeListener(){ @Override public void stateChanged(ChangeEvent e) { JSlider jsl2 = (JSlider)e.getSource();//得到jsl对象 if (!jsl2.getValueIsAdjusting())//判断是否还在移动滑条 System.out.println(jsl2.getValue()); } });