private void putToolTip(Component relativeTo, Point pnt, @Nullable @NlsSafe String text) {
    if (text == null) {
      if (myToolTip.getParent() == this) {
        remove(myToolTip);
        repaint();
      }
    }
    else {
      String oldText = myToolTip.getTipText();
      myToolTip.setTipText(text);

      pnt = SwingUtilities.convertPoint(relativeTo, pnt, this);
      Dimension prefSize = myToolTip.getPreferredSize();
      pnt.x = Math.min(pnt.x, getBounds().width - prefSize.width);
      pnt.y = Math.min(pnt.y, getBounds().height - prefSize.height);
      myToolTip.setBounds(pnt.x, pnt.y, prefSize.width, prefSize.height);
      if (myToolTip.getParent() != this) {
        add(myToolTip);
        repaint();
      }
      else if (!text.equals(oldText)) {
        myToolTip.repaint();
      }
    }
  }
private void putToolTip(Component relativeTo, Point pnt, @Nullable @NlsSafe String text)