if (textComponent == null)
JTextComponent comp = getComponent(); if (comp == null)
  public void paint(Graphics g)  {    if (textComponent == null)      return;    int dot = getDot();    Rectangle rect = null;    try      {	rect = textComponent.modelToView(dot);      }    catch (BadLocationException e)      {	// This should never happen as dot should be always valid.	return;      }    if (rect == null)      return;        // First we need to delete the old caret.    // FIXME: Implement deleting of old caret.        // Now draw the caret on the new position if visible.    if (visible)      {	g.setColor(textComponent.getCaretColor());	g.drawLine(rect.x, rect.y, rect.x, rect.y + rect.height);      }  }