I have a JScrollPane with a very high JPanel inside, that is changed dynamically, items being appended at its end. What I want, is to scroll to the bottom of aforementioned JScrollPane in order for the newly appended items to be visible instantly on addition (they are not appended to the scroll pane directly, but to its JPanel, and are private objects, so cannot be referenced.
How can I simply have that scroll pane scroll to the very bottom?
Thanks in advance!
JComponent.scrollRectToVisible(Rectangle). Call that on theJPanelinstance.E.G.
Screen shot
E.G. 2
This e.g. is based on Vincent’s answer, to use
JScrollPane.getVerticalScrollBar().setValue(height). Whereheightis the preferred height of the panel in pixels.