JToolTip tip = (JToolTip) c;  String text = tip.getTipText(); Toolkit t = tip.getToolkit(); if (text == null) return;  Rectangle vr = new Rectangle(); vr = SwingUtilities.calculateInnerArea(tip, vr); Rectangle ir = new Rectangle(); Rectangle tr = new Rectangle(); FontMetrics fm = t.getFontMetrics(tip.getFont()); int ascent = fm.getAscent(); SwingUtilities.layoutCompoundLabel(tip, fm, text, null, SwingConstants.CENTER, SwingConstants.LEFT, SwingConstants.CENTER, SwingConstants.CENTER, vr, ir, tr, 0); Color saved = g.getColor(); g.setColor(Color.BLACK);  g.drawString(text, vr.x, vr.y + ascent);   if (acceleratorString != null) { g.setFont(acceleratorFont); g.setColor(acceleratorForeground); fm = t.getFontMetrics(acceleratorFont); int width = fm.stringWidth(acceleratorString); g.drawString(acceleratorString, vr.x + vr.width - width - padSpaceBetweenStrings / 2, vr.y + vr.height - fm.getDescent()); }  g.setColor(saved);
super.paint(g, c);
  public void paint(Graphics g, JComponent c)  {    JToolTip tip = (JToolTip) c;    String text = tip.getTipText();    Toolkit t = tip.getToolkit();    if (text == null)      return;    Rectangle vr = new Rectangle();    vr = SwingUtilities.calculateInnerArea(tip, vr);    Rectangle ir = new Rectangle();    Rectangle tr = new Rectangle();    FontMetrics fm = t.getFontMetrics(tip.getFont());    int ascent = fm.getAscent();    SwingUtilities.layoutCompoundLabel(tip, fm, text, null,             SwingConstants.CENTER, SwingConstants.LEFT,            SwingConstants.CENTER, SwingConstants.CENTER, vr, ir, tr, 0);    Color saved = g.getColor();    g.setColor(Color.BLACK);    g.drawString(text, vr.x, vr.y + ascent);         // paint accelerator    if (acceleratorString != null)      {        g.setFont(acceleratorFont);        g.setColor(acceleratorForeground);        fm = t.getFontMetrics(acceleratorFont);        int width = fm.stringWidth(acceleratorString);        g.drawString(acceleratorString, vr.x + vr.width - width             - padSpaceBetweenStrings / 2, vr.y + vr.height - fm.getDescent());      }    g.setColor(saved);     }