Assuming that you're using JTextArea, the cursor is actually a caret, and can be set with setCaret(). Unfortunately, that takes a position, not a line number as a parameter. However, you should be able to use getLineEndOffset(), and a little bit of logic to accomplish your goal.