Код: Выделить всё
public class Swing1 {
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
createAndShowGUI();
}
});
}
private static void createAndShowGUI() {
JFrame frame = new JFrame("JScrollBar Example");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(300, 200);
frame.setLayout(new BorderLayout());
JScrollBar scrollBar = new JScrollBar(JScrollBar.VERTICAL);
BoundedRangeModel model = new DefaultBoundedRangeModel(0, 80, 0, 80);
scrollBar.setModel(model);
JButton button = new JButton("Change Model");
button.addActionListener(e -> {
model.setRangeProperties(0, 24, -3, 24, false);//VALUE IS 0
System.out.println("Current Value after change: " + model.getValue());
});
frame.add(scrollBar, BorderLayout.EAST);
frame.add(button, BorderLayout.SOUTH);
frame.setVisible(true);
}
}
Подробнее здесь: https://stackoverflow.com/questions/786 ... equal-to-0