Rectangle (TextHitInfo offset) { Point caret = logicalPositionToXY(getCaretModel().getLogicalPosition()); Rectangle r = new Rectangle(caret, new Dimension(1, getLineHeight())); Point p = getContentComponent().getLocationOnScreen(); r.translate(p.x, p.y); return r; }