/** * 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) { ButtonBarBuilder builder = new ButtonBarBuilder(); builder.addGridded(help); builder.addRelatedGap(); builder.addGlue(); builder.addGriddedButtons(buttons); 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) { ButtonBarBuilder builder = new ButtonBarBuilder(); builder.addGlue(); builder.addGriddedButtons(buttons); return builder.getPanel(); }
/** * 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) { ButtonBarBuilder builder = new ButtonBarBuilder(); builder.addGriddedGrowingButtons(buttons); return builder.getPanel(); }
/** * Creates and returns a <code>ButtonBarBuilder</code> with * initialized with a left to right button order. * * @return a button bar builder with button order set to left-to-right */ public static ButtonBarBuilder createLeftToRightBuilder() { ButtonBarBuilder builder = new ButtonBarBuilder(); builder.setLeftToRightButtonOrder(true); return builder; }
JButton[] rightAlignedButtons) { ButtonBarBuilder builder = new ButtonBarBuilder(); if (leftAlignedButtons != null) { builder.addGriddedButtons(leftAlignedButtons); builder.addRelatedGap(); builder.addGlue(); builder.addGridded(back); builder.addGridded(next); builder.nextColumn(-1); builder.add(overlaidFinish); builder.nextColumn(); builder.addRelatedGap(); builder.addGriddedButtons(rightAlignedButtons); 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) { ButtonBarBuilder builder = new ButtonBarBuilder(); builder.addGlue(); builder.addButton(buttons); final JPanel panel = builder.getPanel(); final JPanel outerPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT)); outerPanel.add(panel); return outerPanel; }
/** * 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) { ButtonBarBuilder builder = new ButtonBarBuilder(); builder.addGriddedGrowing(add); builder.addRelatedGap(); builder.addGriddedGrowing(remove); builder.addRelatedGap(); builder.addGriddedGrowing(properties); return builder.getPanel(); }
/** * Adds a gridded component, i.e. a component that will get * the same dimension as all other gridded components. * * @param component the component to add */ public void addGridded(JComponent component) { getLayout().appendColumn(FormFactory.BUTTON_COLSPEC); getLayout().addGroupedColumn(getColumn()); component.putClientProperty(NARROW_KEY, Boolean.TRUE); add(component); nextColumn(); }
/** * Adds a sequence of related gridded buttons each 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 addGriddedButtons(JButton[] buttons) { int length = buttons.length; for (int i = 0; i < length; i++) { int index = leftToRight ? i : length -1 - i; addGridded(buttons[index]); if (i < buttons.length - 1) addRelatedGap(); } }
/** * Sets a default border that has a gap in the bar's north. */ public void setDefaultButtonBarGapBorder() { getPanel().setBorder(Borders.BUTTON_BAR_GAP_BORDER); }
/** * Adds a fixed size component. Unlike the gridded components, * this component keeps its individual preferred dimension. * * @param component the component to add */ public void addFixed(JComponent component) { getLayout().appendColumn(FormFactory.PREF_COLSPEC); add(component); nextColumn(); }
/** * Adds a sequence of gridded buttons that grow 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 addGriddedGrowingButtons(JButton[] buttons) { int length = buttons.length; for (int i = 0; i < length; i++) { int index = leftToRight ? i : length - 1 - i; addGriddedGrowing(buttons[index]); if (i < buttons.length - 1) addRelatedGap(); } }
/** * Adds a fixed size component with narrow margins. Unlike the gridded * components, this component keeps its individual preferred dimension. * * @param component the component to add */ public void addFixedNarrow(JComponent component) { component.putClientProperty(NARROW_KEY, Boolean.TRUE); addFixed(component); }
/** * 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) { ButtonBarBuilder builder = new ButtonBarBuilder(); builder.addGriddedButtons(buttons); builder.addGlue(); return builder.getPanel(); }
ButtonBarBuilder builder = new ButtonBarBuilder(); if (leftAlignedButtons != null) { builder.addGriddedButtons(leftAlignedButtons); builder.addRelatedGap(); builder.addGlue(); builder.addGridded(back); builder.addGridded(next); builder.nextColumn(-1); builder.add(overlayedFinish); builder.nextColumn(); builder.addRelatedGap(); builder.addGriddedButtons(rightAlignedButtons); return builder.getPanel();
/** * 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) { ButtonBarBuilder builder = new ButtonBarBuilder(); builder.addGriddedGrowing(add); builder.addRelatedGap(); builder.addGriddedGrowing(remove); builder.addRelatedGap(); builder.addGriddedGrowing(properties); return builder.getPanel(); }
/** * 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) { ButtonBarBuilder builder = new ButtonBarBuilder(); builder.addGriddedGrowingButtons(buttons); return builder.getPanel(); }
/** * Adds a gridded component that grows. The component's initial size * (before it grows) is the same as for all other gridded components. * * @param component the component to add */ public void addGriddedGrowing(JComponent component) { getLayout().appendColumn(FormFactory.GROWING_BUTTON_COLSPEC); getLayout().addGroupedColumn(getColumn()); component.putClientProperty(NARROW_KEY, Boolean.TRUE); add(component); nextColumn(); }
/** * Adds a sequence of related gridded buttons each 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 addGriddedButtons(JButton[] buttons) { int length = buttons.length; for (int i = 0; i < length; i++) { int index = leftToRight ? i : length - 1 - i; addGridded(buttons[index]); if (i < buttons.length - 1) addRelatedGap(); } }
/** * Creates and returns a <code>ButtonBarBuilder</code> with initialized * with a left to right button order. * * @return a button bar builder with button order set to left-to-right */ public static ButtonBarBuilder createLeftToRightBuilder() { ButtonBarBuilder builder = new ButtonBarBuilder(); builder.setLeftToRightButtonOrder(true); return builder; }