FontMetrics fm = tip.getToolkit().getFontMetrics(tip.getFont()); SwingUtilities.layoutCompoundLabel(tip, fm, tip.getTipText(), null,
FontMetrics fm = t.getFontMetrics(tip.getFont()); int ascent = fm.getAscent(); SwingUtilities.layoutCompoundLabel(tip, fm, text, null,
  public void paint(Graphics g, JComponent c)  {    JToolTip tip = (JToolTip) c;    String text = tip.getTipText();    if (text == null)      return;    Rectangle vr = new Rectangle();    vr = SwingUtilities.calculateInnerArea(tip, vr);    Rectangle ir = new Rectangle();    Rectangle tr = new Rectangle();    FontMetrics fm = tip.getToolkit().getFontMetrics(tip.getFont());    SwingUtilities.layoutCompoundLabel(tip, fm, tip.getTipText(), null,                                       SwingConstants.CENTER,                                       SwingConstants.CENTER,                                       SwingConstants.CENTER,                                       SwingConstants.CENTER, vr, ir, tr, 0);    Color saved = g.getColor();    g.setColor(Color.BLACK);    g.drawString(text, vr.x, vr.y + fm.getAscent());    g.setColor(saved);  }