Rectangle (int offset) { // Since we report the very end of the document as being 1 character past the document // length, we need to validate the offset passed back by the screen reader. if (offset < 0 || offset > myEditor.getDocument().getTextLength() - 1) { return null; } LogicalPosition pos = myEditor.offsetToLogicalPosition(offset); Point point = myEditor.logicalPositionToXY(pos); FontMetrics fontMetrics = myEditor.getFontMetrics(Font.PLAIN); char c = myEditor.getDocument().getCharsSequence().subSequence(offset, offset + 1).charAt(0); return new Rectangle(point.x, point.y, fontMetrics.charWidth(c), fontMetrics.getHeight()); }