Making a JScrollPane automatically scroll all the way down

后端 未结 6 1421
夕颜
夕颜 2021-02-05 07:42

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 thi

6条回答
  •  刺人心
    刺人心 (楼主)
    2021-02-05 08:05

    A work around is possible: you can declare that listener as a class then instantiate it on the event where it is needed. After which you can remove the class after forcing a repaint of the screen. Works like a charm.

提交回复
热议问题