You need to set the preferred size of the JScrollBar components.
scrollpane.getVerticalScrollBar().setPreferredSize(
new Dimension(width, Integer.MAX_VALUE));
scrollpane.getHorizontalScrollBar().setPreferredSize(
new Dimension(Integer.MAX_VALUE, width));
written by objects
\\ tags: JScrollBar, JScrollPane
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);
panel.add(scrollPane);
written by objects
\\ tags: JList, JScrollPane
The JViewport of the JScrollPane provides a method to return the location of top left point showing in the scroll pane.
JViewport viewport = myScrollPane.getViewport();
Point scrolledTo = viewport.getViewPosition();
written by objects
\\ tags: JScrollPane, JViewport
Recent Comments