ScrollPane滚动到底部问题 [英] ScrollPane scroll to bottom problem

查看:319
本文介绍了ScrollPane滚动到底部问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Java应用程序中有TextArea,我在文本行中附加了很多内容。我需要ScrollPane滚动到最后一个附加(到TextArea的底部)。我怎么做?

I have TextArea in my Java app and I append lot off text rows. I need to ScrollPane to scroll to last appended ( to bottom of TextArea ). How I can do that ?

推荐答案

你可以通过将插入位置移动到底部来实现,这会自动滚动TextArea :

You could do that by moving the caret position to the bottom, this would automatically scroll the TextArea:

textArea.setCaretPosition(textArea.getDocument().getLength());

这篇关于ScrollPane滚动到底部问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆