Reputation: 3835
I have a JScrollPane
containing a JPanel
and, in turn, a JList
. I want for the viewport to always show the end of the list (from which items are being removed or added). I can accomplish this manually by dragging the ScrollBar
to the bottom, where it stays, just the way I want it to. What should I do to accomplish this automatically?
Upvotes: 3
Views: 1556
Reputation: 285415
It should be simple to do. Just use JList's ensureIndexIsVisible
method and pass it the last index in the list (size - 1).
Upvotes: 3
Reputation: 1321
You can use "scrollto" call while after creating JScrollPane.
here is the link for documentation. http://jscrollpane.kelvinluck.com/scroll_to.html
Upvotes: -1