/** * Adds a sequence of related JButtons built from the given Actions. * Each button has the minimum width as specified by * {@link LayoutStyle#getDefaultButtonWidth()}. The gap width between * the buttons is {@link LayoutStyle#getRelatedComponentsPadX()}.<p> * * This method is equivalent to * <code>addButton(new Action[]{action1, action2});</code> * * @param action1 describes the first button to add * @param action2 describes the second button to add * * @throws NullPointerException if an Action is {@code null} * * @see #addButton(Action[]) * @see #addButton(JComponent[]) */ public void addButton( Action action1, Action action2) { addButton(new Action[]{action1, action2}); }
/** * Adds a sequence of related button components. * Each button has the minimum width as specified by * {@link LayoutStyle#getDefaultButtonWidth()}. The gap width between * the buttons is {@link LayoutStyle#getRelatedComponentsPadX()}.<p> * * This method is equivalent to * <code>addButton(new JComponent[]{button1, button2});</code> * * @param button1 the first button to add * @param button2 the second button to add * * @throws NullPointerException if a button is {@code null} * * @see #addButton(JComponent[]) */ public void addButton( JComponent button1, JComponent button2) { addButton(new JComponent[]{button1, button2}); }
/** * Adds a sequence of related button components. * Each button has the minimum width as specified by * {@link LayoutStyle#getDefaultButtonWidth()}. The gap width between * the buttons is {@link LayoutStyle#getRelatedComponentsPadX()}.<p> * * This method is equivalent to * <code>addButton(new JComponent[]{button1, button2, button3});</code> * * @param button1 the first button to add * @param button2 the second button to add * @param button3 the third button to add * * @throws NullPointerException if a button is {@code null} * * @see #addButton(JComponent[]) */ public void addButton( JComponent button1, JComponent button2, JComponent button3) { addButton(new JComponent[]{button1, button2, button3}); }
/** * Adds a sequence of related button components. * Each button has the minimum width as specified by * {@link LayoutStyle#getDefaultButtonWidth()}. The gap width between * the buttons is {@link LayoutStyle#getRelatedComponentsPadX()}.<p> * * This method is equivalent to * <code>addButton(new JComponent[]{button1, button2, button3, button4});</code> * * @param button1 the first button to add * @param button2 the second button to add * @param button3 the third button to add * @param button4 the fourth button to add * * @throws NullPointerException if a button is {@code null} * * @see #addButton(JComponent[]) */ public void addButton( JComponent button1, JComponent button2, JComponent button3, JComponent button4) { addButton(new JComponent[]{button1, button2, button3, button4}); }
/** * Adds a sequence of related JButtons built from the given Actions. * Each button has the minimum width as specified by * {@link LayoutStyle#getDefaultButtonWidth()}. The gap width between * the buttons is {@link LayoutStyle#getRelatedComponentsPadX()}.<p> * * This method is equivalent to * <code>addButton(new Action[]{action1, action2, action3});</code> * * @param action1 describes the first button to add * @param action2 describes the second button to add * @param action3 describes the third button to add * * @throws NullPointerException if an Action is {@code null} * * @see #addButton(Action[]) * @see #addButton(JComponent[]) */ public void addButton( Action action1, Action action2, Action action3) { addButton(new Action[]{action1, action2, action3}); }
/** * Adds a sequence of related JButtons built from the given Actions. * Each button has the minimum width as specified by * {@link LayoutStyle#getDefaultButtonWidth()}. The gap width between * the buttons is {@link LayoutStyle#getRelatedComponentsPadX()}.<p> * * This method is equivalent to * <code>addButton(new Action[]{action1, action2, action3, action4});</code> * * @param action1 describes the first button to add * @param action2 describes the second button to add * @param action3 describes the third button to add * @param action4 describes the fourth button to add * * @throws NullPointerException if an Action is {@code null} * * @see #addButton(Action[]) * @see #addButton(JComponent[]) */ public void addButton( Action action1, Action action2, Action action3, Action action4) { addButton(new Action[]{action1, action2, action3, action4}); }
/** * Adds a sequence of related button components. * Each button has the minimum width as specified by * {@link LayoutStyle#getDefaultButtonWidth()}. The gap width between * the buttons is {@link LayoutStyle#getRelatedComponentsPadX()}.<p> * * This method is equivalent to * <code>addButton(new JComponent[]{button1, button2, button3, button4, button5});</code> * * @param button1 the first button to add * @param button2 the second button to add * @param button3 the third button to add * @param button4 the fourth button to add * @param button5 the fifth button to add * * @throws NullPointerException if a button is {@code null} * * @see #addButton(JComponent[]) */ public void addButton( JComponent button1, JComponent button2, JComponent button3, JComponent button4, JComponent button5) { addButton(new JComponent[]{button1, button2, button3, button4, button5}); }
/** * 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 * * @throws NullPointerException if {@code action} is {@code null} * * @see #addButton(JComponent) */ public void addButton(Action action) { if (action == null) throw new NullPointerException("The button Action must not be null."); addButton(new JButton(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 * * @throws NullPointerException if the Action array or an Action is {@code null} * @throws IllegalArgumentException if the Action array is empty * * @see #addButton(JComponent[]) */ public void addButton(Action[] actions) { if (actions == null) throw new NullPointerException("The Action array must not be null."); int length = actions.length; if (length == 0) throw new IllegalArgumentException("The Action array must not be empty."); JButton[] buttons = new JButton[length]; for (int i = 0; i < length; i++) { buttons[i] = new JButton(actions[i]); } addButton(buttons); }
for (int i = 0; i < length; i++) { int index = leftToRight ? i : length -1 - i; addButton(buttons[index]); if (i < buttons.length - 1) addRelatedGap();
/** * Builds and returns a filled button bar with Add, Remove, and * Properties. * * @param add the Add button * @param remove the Remove button * @param properties the Properties button * @return a panel that contains the button(s) */ public static JPanel buildAddRemovePropertiesBar( JButton add, JButton remove, JButton properties) { ButtonBarBuilder2 builder = new ButtonBarBuilder2(); builder.addButton(add); builder.addRelatedGap(); builder.addButton(remove); builder.addRelatedGap(); builder.addButton(properties); return builder.getPanel(); }
/** * 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)); }
/** * Builds and returns a right aligned bar with help and other buttons. * * @param help the help button to add on the left side * @param buttons an array of buttons to add * @return a right aligned button bar with the given buttons */ public static JPanel buildHelpBar(JButton help, JButton... buttons) { ButtonBarBuilder2 builder = new ButtonBarBuilder2(); builder.addButton(help); builder.addUnrelatedGap(); builder.addGlue(); builder.addButton(buttons); return builder.getPanel(); }
/** * Builds and returns a left aligned button bar with the given buttons. * * @param buttons an array of buttons to add * @return a left aligned button bar with the given buttons */ public static JPanel buildLeftAlignedBar(JButton... buttons) { ButtonBarBuilder2 builder = new ButtonBarBuilder2(); builder.addButton(buttons); builder.addGlue(); return builder.getPanel(); }
/** * Builds and returns a right aligned button bar with the given buttons. * * @param buttons an array of buttons to add * @return a right aligned button bar with the given buttons */ public static JPanel buildRightAlignedBar(JButton... buttons) { ButtonBarBuilder2 builder = new ButtonBarBuilder2(); builder.addGlue(); builder.addButton(buttons); return builder.getPanel(); }
/** * Builds and returns a centered button bar with the given buttons. * * @param buttons an array of buttons to add * @return a centered button bar with the given buttons */ public static JPanel buildCenteredBar(JButton... buttons) { ButtonBarBuilder2 builder = new ButtonBarBuilder2(); builder.addGlue(); builder.addButton(buttons); builder.addGlue(); return builder.getPanel(); }
/** * 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); }
/** * Builds and returns a left aligned button bar with the given buttons. * * @param buttons an array of buttons to add * @param leftToRightButtonOrder the order in which the buttons to add * @return a left aligned button bar with the given buttons */ public static JPanel buildLeftAlignedBar( JButton[] buttons, boolean leftToRightButtonOrder) { ButtonBarBuilder2 builder = new ButtonBarBuilder2(); builder.setLeftToRightButtonOrder(leftToRightButtonOrder); builder.addButton(buttons); builder.addGlue(); return builder.getPanel(); }
/** * Builds and returns a right aligned button bar with the given buttons. * * @param buttons an array of buttons to add * @param leftToRightButtonOrder the order in which the buttons to add * @return a right aligned button bar with the given buttons */ public static JPanel buildRightAlignedBar( JButton[] buttons, boolean leftToRightButtonOrder) { ButtonBarBuilder2 builder = new ButtonBarBuilder2(); builder.setLeftToRightButtonOrder(leftToRightButtonOrder); builder.addGlue(); builder.addButton(buttons); return builder.getPanel(); }
for (int i = 0; i < length; i++) { int index = leftToRight ? i : length -1 - i; addButton(buttons[index]); if (i < buttons.length - 1) { addRelatedGap();