@Override
  public Dimension getPreferredSize() {
    int iconSize = getIcon().getIconWidth();
    final FontMetrics metrics = getFontMetrics(getFont());
    final int textWidth = metrics.stringWidth(getText());
    final int width = myLeftRightBorder + iconSize + myHGap + textWidth + myLeftRightBorder;
    final int height = myTopBottomBorder + Math.max(iconSize, metrics.getHeight()) + myTopBottomBorder;
    return new Dimension(width, height);
  }
@Override
  public Dimension getPreferredSize()