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