Is there possible to move text cursor in TextArea (or other text component)? How? is there a function to do that?

Assume, we have a TextArea and 2 button. Each time we press the first button, the text cursor will go to the position between second letter and third letter. If only two letter, the text cursor will go to the end of string. Each time we press the second button, the text cursor will go to the beginning of string.

Could anybody help me? Thx before :D

有帮助吗?

解决方案

Is there possible to move text cursor in TextArea

Its called a caret in Java. Check out the API for methods with caret in the method name. For example:

textArea.setCaretPosition( textArea.getCaretPosition() + 1 );
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top