static void selectLineInTextArea(final JTextArea ta, final int line) { swing { S text = getText(ta); int i = lineNrToCharIndex(text, line); int j = lineNrToCharIndex(text, line+1); ta.select(i, j); } }