AWT/Swing中TextArea/JTextArea使用setCaretPosition方法
public void setCaretPosition(int position)
The caret position is constrained to be between 0 and the last character of the text, inclusive.
JavaFX中:
TextArea ta = new TextArea();
ta.setText("1234567890");
ta.positionCaret(4);