@Override protected void paintComponent(Graphics g) { super.paintComponent(g); Graphics2D g2 = (Graphics2D) g; Insets i = getInsets(); // int y = g2.getFontMetrics().getHeight()*getLineAtCaret(this)+i.top; int y = caret.y + caret.height - 1; g2.setPaint(cfc); g2.drawLine(i.left, y, getSize().width - i.left - i.right, y); }