There’s a method in JComponent called scrollRectToVisible() which interacts with the parent scroll pane (if one exists) to change its viewport. It takes a Rectangle as an argument that specifies the area you want to be visible in the viewport.
So for example to scroll to a given row in a JTable you would use something like this:
0, row * table.getRowHeight(),
You need to set the preferred size of the JScrollBar components.
new Dimension(width, Integer.MAX_VALUE));
new Dimension(Integer.MAX_VALUE, width));
You need to add your JList (or any component) to a JScrollPane. Easiest way to do this is to pass your component to the JScrollPane’s constructor. You then add the JScrollPane to your component hierarchy (instead of adding your JList).
JScrollPane scrollPne = new JScrollPane(mylist);