public void paint (Graphics g) {
    if (fm == null) {
      fm = g.getFontMetrics (font);
      titleFm = g.getFontMetrics (titleFont);

      minSize.width = titleFm.stringWidth (title);
      minSize.height = 1 + TITLE_ABOVE_SPACE + titleFm.getHeight() + TITLE_BELOW_SPACE;

      for (int i = 0; i < items.length; i++) {
	minSize.height += ITEM_ABOVE_SPACE;
        if (items[i].equals ("-")) {
	  minSize.height += DIVIDER_HEIGHT;
	} else {
	  minSize.height += fm.getHeight();
	  if (fm.stringWidth (items[i]) > minSize.width)
	    minSize.width = fm.stringWidth (items[i]);
	}
	minSize.height += ITEM_BELOW_SPACE;
      }
      minSize.width += (MATTE_SIZE+1) * 2;
      minSize.height++;
      resize (minSize);
      repaint();

    } else {
      g.setColor (borderColor);
      g.drawLine (0, 0, 0, size().height-1);
      g.drawLine (0, 0, size().width-1, 0);
      g.drawLine (size().width-1, 0, size().width-1, size().height-1);
      g.drawLine (0, size().height-1, size().width-1, size().height-1);

      int y = 1 + TITLE_ABOVE_SPACE;

      g.setFont (titleFont);
      g.setColor (titleColor);
      g.drawString (title, size().width/2 - titleFm.stringWidth(title)/2,
                    y + titleFm.getAscent());
      y += titleFm.getHeight() + TITLE_BELOW_SPACE;

      g.setFont (font);
      for (int i = 0; i < items.length; i++) {
        if (items[i].equals ("-")) {
	  g.setColor (dividerColor);
	  g.drawLine (1, y + ITEM_ABOVE_SPACE, size().width-2, y + ITEM_ABOVE_SPACE);
	  y += DIVIDER_HEIGHT;
	}
	else {
	  if (selected == i) {
            g.setColor (selectedBgColor);
            g.fillRect (1, y, size().width-2, fm.getHeight() + ITEM_ABOVE_SPACE + ITEM_BELOW_SPACE);
            g.setColor (selectedFgColor);
	  } else
	    g.setColor (fgColor);
	  g.drawString (items[i], 1 + MATTE_SIZE, y + ITEM_ABOVE_SPACE + fm.getAscent());
	  y += fm.getHeight();
	}
	y += ITEM_ABOVE_SPACE + ITEM_BELOW_SPACE;
      }
    }
  }