/** * Adds a sequence of related growing buttons * where each is separated by a default gap. * Honors this builder's button order. If you * want to use a fixed left to right order, * add individual buttons. * * @param buttons an array of buttons to add * * @see LayoutStyle */ public void addGrowing(JComponent[] buttons) { int length = buttons.length; for (int i = 0; i < length; i++) { int index = leftToRight ? i : length -1 - i; addGrowing(buttons[index]); if (i < buttons.length - 1) addRelatedGap(); } }
/** * Adds a sequence of related growing buttons * where each is separated by a default gap. * Honors this builder's button order. If you * want to use a fixed left to right order, * add individual buttons. * * @param buttons an array of buttons to add * * @return this builder * * @see LayoutStyle */ public ButtonBarBuilder2 addGrowing(JComponent... buttons) { int length = buttons.length; for (int i = 0; i < length; i++) { int index = leftToRight ? i : length -1 - i; addGrowing(buttons[index]); if (i < buttons.length - 1) { addRelatedGap(); } } return this; }
/** * Builds and returns a button bar with the given buttons. All button * columns will grow with the bar. * * @param buttons an array of buttons to add * @return a filled button bar with the given buttons */ public static JPanel buildGrowingBar(JButton... buttons) { ButtonBarBuilder2 builder = new ButtonBarBuilder2(); builder.addGrowing(buttons); return builder.getPanel(); }