I am trying to implement a JScrollPane with a JTextArea. The JTextArea is being appended to, and I want the JScrollPane to keep scrolling down as more text is added. How can this be achieved?
A:
I found the answer here: http://stackoverflow.com/questions/2132444/jscrollpane-and-jlist-auto-scroll
scrollPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() {
public void adjustmentValueChanged(AdjustmentEvent e) {
e.getAdjustable().setValue(e.getAdjustable().getMaximum());
}
});
Krigath
2010-03-20 15:38:48
Your "solution" is actually the problem of the linked-to question: if you manually try to move the vertical scroll handle, this code will scroll to the bottom again!
jackrabbit
2010-03-20 17:09:30
+3
A:
For (what I think is) a simpler answer check out: Text Area Scrolling.
camickr
2010-03-20 16:32:48