boolean (Editor e, TextRange r) { int startOffset = r.getStartOffset(); if (startOffset > e.getDocument().getTextLength()) return false; Rectangle visibleArea = e.getScrollingModel().getVisibleArea(); Point point = e.logicalPositionToXY(e.offsetToLogicalPosition(startOffset)); return visibleArea.contains(point); }