JAVA – Set The Position Of The ScrollBar In JScrollPane()
The following codes assumes that you have created a JScrollPane() called scrollPane
int x = 0;
int y = 10;
scrollPane.getViewport().setViewPosition(new java.awt.Point(x, y));
In this example x sets the horizontal position of a horizontal scroll bar.
y sets the vertical position of a vertical scroll bar – in this case the vertical scroll bar will appear 10 pixels down from the top.