void () { int bound = getEditor().getDocument().getTextLength() + 1; int offset1 = myRandom.nextInt(bound); int offset2 = myRandom.nextInt(bound); getEditor().getMarkupModel().addRangeHighlighter(null, Math.min(offset1, offset2), Math.max(offset1, offset2), 0, HighlighterTargetArea.EXACT_RANGE); }