JTextArea scroll to bottom only if text is appended

后端 未结 2 1997
不知归路
不知归路 2021-01-26 10:21

I am trying to create a JTextArea which scrolls to bottom every time a text is appended to that text area. Otherwise, the user should be able to scroll top and see

2条回答
  •  执念已碎
    2021-01-26 11:10

    Check out Smart Scrolling.

    If the scrollbar is at the bottom, then as text is appended you will see the new text.

    If the user has scrolled to a different position, then the viewport will stay there until the user scrolls back to the bottom.

提交回复
热议问题