protected Rectangle rectangleForArrowIcon() {
    Rectangle b = comboBox.getBounds();
    Border border = comboBox.getBorder();
    Insets in;
    if (border != null) {
      in = border.getBorderInsets(comboBox);
    } else {
      in = new Insets(0, 0, 0, 0);
    }
    b.x = in.left;
    b.y = in.top;
    b.width -= (in.left + in.right);
    b.height -= (in.top + in.bottom);

    if (MotifGraphicsUtils.isLeftToRight(comboBox)) {
      b.x = b.x + b.width - HORIZ_MARGIN - arrowIcon.getIconWidth();
    } else {
      b.x += HORIZ_MARGIN;
    }
    b.y = b.y + (b.height - arrowIcon.getIconHeight()) / 2;
    b.width = arrowIcon.getIconWidth();
    b.height = arrowIcon.getIconHeight();
    return b;
  }
  /**
   * Compute and return the location of the icons origin, the location of origin of the text
   * baseline, and a possibly clipped version of the compound labels string. Locations are computed
   * relative to the viewR rectangle.
   */
  private static String layoutMenuItem(
      JComponent c,
      FontMetrics fm,
      String text,
      FontMetrics fmAccel,
      String acceleratorText,
      Icon icon,
      Icon checkIcon,
      Icon arrowIcon,
      int verticalAlignment,
      int horizontalAlignment,
      int verticalTextPosition,
      int horizontalTextPosition,
      Rectangle viewR,
      Rectangle iconR,
      Rectangle textR,
      Rectangle acceleratorR,
      Rectangle checkIconR,
      Rectangle arrowIconR,
      int textIconGap,
      int menuItemGap) {

    SwingUtilities.layoutCompoundLabel(
        c,
        fm,
        text,
        icon,
        verticalAlignment,
        horizontalAlignment,
        verticalTextPosition,
        horizontalTextPosition,
        viewR,
        iconR,
        textR,
        textIconGap);

    /* Initialize the acceelratorText bounds rectangle textR.  If a null
     * or and empty String was specified we substitute "" here
     * and use 0,0,0,0 for acceleratorTextR.
     */
    if ((acceleratorText == null) || acceleratorText.equals("")) {
      acceleratorR.width = acceleratorR.height = 0;
      acceleratorText = "";
    } else {
      acceleratorR.width = SwingUtilities2.stringWidth(c, fmAccel, acceleratorText);
      acceleratorR.height = fmAccel.getHeight();
    }

    /* Initialize the checkIcon bounds rectangle checkIconR.
     */

    if (checkIcon != null) {
      checkIconR.width = checkIcon.getIconWidth();
      checkIconR.height = checkIcon.getIconHeight();
    } else {
      checkIconR.width = checkIconR.height = 0;
    }

    /* Initialize the arrowIcon bounds rectangle arrowIconR.
     */

    if (arrowIcon != null) {
      arrowIconR.width = arrowIcon.getIconWidth();
      arrowIconR.height = arrowIcon.getIconHeight();
    } else {
      arrowIconR.width = arrowIconR.height = 0;
    }

    Rectangle labelR = iconR.union(textR);
    if (MotifGraphicsUtils.isLeftToRight(c)) {
      textR.x += checkIconR.width + menuItemGap;
      iconR.x += checkIconR.width + menuItemGap;

      // Position the Accelerator text rect
      acceleratorR.x = viewR.x + viewR.width - arrowIconR.width - menuItemGap - acceleratorR.width;

      // Position the Check and Arrow Icons
      checkIconR.x = viewR.x;
      arrowIconR.x = viewR.x + viewR.width - menuItemGap - arrowIconR.width;
    } else {
      textR.x -= (checkIconR.width + menuItemGap);
      iconR.x -= (checkIconR.width + menuItemGap);

      // Position the Accelerator text rect
      acceleratorR.x = viewR.x + arrowIconR.width + menuItemGap;

      // Position the Check and Arrow Icons
      checkIconR.x = viewR.x + viewR.width - checkIconR.width;
      arrowIconR.x = viewR.x + menuItemGap;
    }

    // Align the accelertor text and the check and arrow icons vertically
    // with the center of the label rect.
    acceleratorR.y = labelR.y + (labelR.height / 2) - (acceleratorR.height / 2);
    arrowIconR.y = labelR.y + (labelR.height / 2) - (arrowIconR.height / 2);
    checkIconR.y = labelR.y + (labelR.height / 2) - (checkIconR.height / 2);

    /*
    System.out.println("Layout: v=" +viewR+"  c="+checkIconR+" i="+
    iconR+" t="+textR+" acc="+acceleratorR+" a="+arrowIconR);
    */
    return text;
  }
  public static Dimension getPreferredSize(AbstractButton b) {
    String style = (String) b.getClientProperty("Quaqua.Button.style");
    if (style == null) {
      style = "push";
    }
    if (style.equals("help")) {
      Icon helpIcon = UIManager.getIcon("Button.helpIcon");
      Insets insets = b.getInsets();

      return new Dimension(
          helpIcon.getIconWidth() + insets.left + insets.right,
          helpIcon.getIconHeight() + insets.top + insets.bottom);
    }
    if (b.getComponentCount() > 0) {
      return null;
    }

    int textIconGap = Methods.invokeGetter(b, "getIconTextGap", 4);
    Icon icon = (Icon) b.getIcon();
    String text = b.getText();

    Font font = b.getFont();
    FontMetrics fm = b.getFontMetrics(font);

    viewR.x = viewR.y = 0;
    viewR.width = Short.MAX_VALUE;
    viewR.height = Short.MAX_VALUE;
    iconR.x = iconR.y = iconR.width = iconR.height = 0;
    textR.x = textR.y = textR.width = textR.height = 0;

    SwingUtilities.layoutCompoundLabel(
        (JComponent) b,
        fm,
        text,
        icon,
        b.getVerticalAlignment(),
        b.getHorizontalAlignment(),
        b.getVerticalTextPosition(),
        b.getHorizontalTextPosition(),
        viewR,
        iconR,
        textR,
        (text == null ? 0 : textIconGap));

    /* The preferred size of the button is the size of
     * the text and icon rectangles plus the buttons insets.
     */

    Rectangle r = iconR.union(textR);

    // if (b.isBorderPainted()) {
    Insets insets = b.getInsets();
    r.width += insets.left + insets.right;
    r.height += insets.top + insets.bottom;
    // }
    if (!QuaquaUtilities.isSmallSizeVariant(b)
        && style.equals("push")
        && b.getIcon() == null
        && b.getText() != null) {
      r.width = Math.max(r.width, UIManager.getInt("Button.minimumWidth"));
    }
    return r.getSize();
  }