if (isAcceleratorHidden()) return super.getPreferredSize(c); else { Insets insets = c.getInsets(); JToolTip tt = (JToolTip) c; String tipText = tt.getTipText(); if (tipText != null)
Dimension d = super.getPreferredSize(c); String acc = getAcceleratorString(); if (acc != null && ! acc.equals(""))
  public Dimension getPreferredSize(JComponent c)  {    if (isAcceleratorHidden())      return super.getPreferredSize(c);    else      {        Insets insets = c.getInsets();        JToolTip tt = (JToolTip) c;        String tipText = tt.getTipText();        if (tipText != null)          {            FontMetrics fm = c.getFontMetrics(c.getFont());            int prefH = fm.getHeight() + insets.top + insets.bottom;            int prefW = fm.stringWidth(tipText) + insets.left + insets.right;            // this seems to be the first opportunity we have to get the             // accelerator string from the component (if it has one)            acceleratorString = fetchAcceleratorString(c);            if (acceleratorString != null)              {                prefW += padSpaceBetweenStrings;                fm = c.getFontMetrics(acceleratorFont);                prefW += fm.stringWidth(acceleratorString);                              }            return new Dimension(prefW, prefH);            }        else return new Dimension(0, 0);      }  }