Question

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

Était-ce utile?

La solution

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 );
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top