void (int position) { Document document = getDocument(); if (position > document.getTextLength() || position < 0) { throw new IllegalArgumentException("bad position: " + position); } Editor editor = getEditor(); if (editor != null) { editor.getCaretModel().moveToOffset(position); } else { myCaretPosition = position; } }