/** * Adds a JButton for the given Action that has a minimum width * specified by the {@link LayoutStyle#getDefaultButtonWidth()}. * * @param action the action that describes the button to add * * @return this builder * * @throws NullPointerException if {@code action} is {@code null} * * @see #addButton(JComponent) */ public ButtonBarBuilder2 addButton(Action action) { checkNotNull(action, "The button Action must not be null."); return addButton(createButton(action)); }
/** * Adds a sequence of related JButtons built from the given Actions * that are separated by the default gap as specified by * {@link LayoutStyle#getRelatedComponentsPadX()}.<p> * * Uses this builder's button order (left-to-right vs. right-to-left). * If you want to use a fixed order, add individual Actions instead. * * @param actions the Actions that describe the buttons to add * * @return this builder * * @throws NullPointerException if the Action array or an Action is {@code null} * @throws IllegalArgumentException if the Action array is empty * * @see #addButton(JComponent[]) */ public ButtonBarBuilder2 addButton(Action... actions) { checkNotNull(actions, "The Action array must not be null."); int length = actions.length; checkArgument(length > 0, "The Action array must not be empty."); JButton[] buttons = new JButton[length]; for (int i = 0; i < length; i++) { buttons[i] = createButton(actions[i]); } return addButton(buttons); }