public static void checkResizePoliciesConsistency(AbstractRibbonBand ribbonBand) {
    Insets ins = ribbonBand.getInsets();
    AbstractBandControlPanel controlPanel = ribbonBand.getControlPanel();
    if (controlPanel == null) return;
    int height =
        controlPanel.getPreferredSize().height
            + ribbonBand.getUI().getBandTitleHeight()
            + ins.top
            + ins.bottom;
    List<RibbonBandResizePolicy> resizePolicies = ribbonBand.getResizePolicies();
    checkResizePoliciesConsistencyBase(ribbonBand);
    for (int i = 0; i < (resizePolicies.size() - 1); i++) {
      RibbonBandResizePolicy policy1 = resizePolicies.get(i);
      RibbonBandResizePolicy policy2 = resizePolicies.get(i + 1);
      int width1 = policy1.getPreferredWidth(height, 4);
      int width2 = policy2.getPreferredWidth(height, 4);
      if (width1 < width2) {
        // create the trace message
        StringBuilder builder = new StringBuilder();
        builder.append("Inconsistent preferred widths\n");
        builder.append(
            "Ribbon band '" + ribbonBand.getTitle() + "' has the following resize policies\n");
        for (int j = 0; j < resizePolicies.size(); j++) {
          RibbonBandResizePolicy policy = resizePolicies.get(j);
          int width = policy.getPreferredWidth(height, 4);
          builder.append(
              "\t" + policy.getClass().getName() + " with preferred width " + width + "\n");
        }
        builder.append(
            policy1.getClass().getName()
                + " with pref width "
                + width1
                + " is followed by resize policy "
                + policy2.getClass().getName()
                + " with larger pref width\n");

        throw new IllegalStateException(builder.toString());
      }
    }
  }
 public static void checkResizePoliciesConsistencyBase(AbstractRibbonBand ribbonBand) {
   List<RibbonBandResizePolicy> resizePolicies = ribbonBand.getResizePolicies();
   if (resizePolicies.size() == 0) {
     throw new IllegalStateException("Resize policy list is empty");
   }
   for (int i = 0; i < resizePolicies.size(); i++) {
     RibbonBandResizePolicy policy = resizePolicies.get(i);
     boolean isIcon = policy instanceof IconRibbonBandResizePolicy;
     if (isIcon && (i < (resizePolicies.size() - 1))) {
       throw new IllegalStateException("Icon resize policy must be the last in the list");
     }
   }
 }
 /**
  * Returns a ribbon band expand icon.
  *
  * @return Ribbon band expand icon.
  */
 public static ResizableIcon getRibbonBandExpandIcon(AbstractRibbonBand ribbonBand) {
   boolean ltr = ribbonBand.getComponentOrientation().isLeftToRight();
   return new ArrowResizableIcon(9, ltr ? SwingConstants.EAST : SwingConstants.WEST);
 }