Rectangle () { int caretOffset = myHostEditor.getCaretModel().getOffset(); Point caretPoint = myHostEditor.offsetToXY(caretOffset); int width = myHostEditor.getContentComponent().getWidth() - (caretPoint.x - myHostEditor.getContentComponent().getX()); int height = myHostEditor.getLineHeight(); Rectangle bounds = myHostEditor.getContentComponent().getVisibleRect(); Rectangle lineBounds = new Rectangle(caretPoint.x, caretPoint.y, width, height); if (bounds == null) { return null; } if (bounds.y > lineBounds.y || bounds.y + bounds.height < lineBounds.y + lineBounds.height) { return null; } bounds.y = lineBounds.y; bounds.height = lineBounds.height; if(lineBounds.x > bounds.x) { bounds.width = bounds.width - lineBounds.x + bounds.x - UIUtil.getScrollBarWidth(); bounds.x = lineBounds.x; } return bounds; }