Graphics g = progressBar.getGraphics();
  public Dimension getPreferredSize(JComponent c)  {    // The only thing we need to worry about is    // the text size.    Graphics g = progressBar.getGraphics();    Insets insets = c.getInsets();    FontMetrics fm = g.getFontMetrics(c.getFont());    int textW = fm.stringWidth(progressBar.getString());    int textH = fm.getHeight();    g.dispose();    if (progressBar.getOrientation() == JProgressBar.HORIZONTAL)      {	if (textH < 20)	  textH = 20;	if (textW < 200)	  textW = 200;      }    else      {	if (textH < 200)	  textH = 200;	if (textW < 20)	  textW = 20;      }    textW += insets.left + insets.right;    textH += insets.top + insets.bottom;    return new Dimension(textW, textH);  }