Code
int step = 5;
int extent = 20;
int min = 0;
int max = extent*10; //200
int value = 50;
final JScrollBar scrollbar = new JScrollBar(
JScrollBar.HORIZONTAL, value, extent, min, max+extent);
scrollbar.setUnitIncrement(step);
scrollbar.getModel().addChangeListener(new ChangeListener(){
public void stateChanged(javax.swing.event.ChangeEvent e) {
BoundedRangeModel m = (BoundedRangeModel)e.getSource();
spinner.setValue(m.getValue());
}
});
final JSpinner spinner = new JSpinner(
new SpinnerNumberModel(value, min, max, step));
//...
References
No comments:
Post a Comment