I have a JScrollPane that contains a JPanel of size 5000x5000 pixels. I want to limit the JScrollPane to only be able to show a subpart of this JPanel.
For example the rectangle defined by the two points (X,Y):
- (500,500) (upper left corner)
- (3000,3000) (lower right corner).
I have tried
myJScrollPane.getHorizontalScrollBar().setMinimum(500);
and
myJScrollPane.getHorizontalScrollBar().setMaximum(3000);
But it doesn't work. The setMinimum function only sets the position of the viewport on the scrollpane, setMaximum doesn't do anything.