如何更改JTextArea中光标的默认位置? [英] How to change the default position of a cursor in a JTextArea?
本文介绍了如何更改JTextArea中光标的默认位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个 _result
JtextArea。每秒都有一个新的文本 String
附加到它。
默认情况下,光标在顶部。
我需要光标总是在JTextArea中的文本的最后。所以我可以看到附加的最后一个字符串是什么。
I have a _result
JtextArea. Every second there is a new piece of text String
being appended to it.
By default, the cursor is at the top.
I need the cursor always to be at the very end of the text in the JTextArea. So that I could see what is the last String being appended.
_result.append("my text");
// How do I make the cursor of `_result` JTextArea to be at the end of the text?
推荐答案
也许这会有帮助。
_result.setCaretPosition(_result.getText().length());
这篇关于如何更改JTextArea中光标的默认位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文