Class ButtonPanelFactory


  • public class ButtonPanelFactory
    extends java.lang.Object
    Class with static methods to create a JButton with a raised bevel border, and to create a JPanel with buttons created by calling the createButton() method.
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int ARROW_DOWN_TYPE
      Button that has a down arrow.
      static int ARROW_LEFT_TYPE
      Button that has a left arrow.
      static int ARROW_RIGHT_TYPE
      Button that has a right arrow.
      static java.awt.Dimension ARROW_SIZE
      Dimension for the arrow button.
      static int ARROW_UP_TYPE
      Button that has an up arrow.
      static java.awt.Font BROWSE_FONT
      Font for the browse button label.
      static javax.swing.Icon BROWSE_ICON
      Text for the browse button.
      static java.awt.Dimension BROWSE_SIZE
      Dimension for the browse button.
      static int BROWSE_TYPE
      Button that indicates a file chooser to browse.
      static int CANCEL_TYPE
      Button for cancel.
      static int EDIT_TYPE
      Button that indicates an edit operation.
      static int OK_TYPE
      Button for OK.
      static char X_AXIS
      layout the buttons on the panel created with createButtonPanel() horizontally along the X-axis
      static char Y_AXIS
      layout the buttons on the panel created with createButtonPanel() vertically along the Y-axis
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static javax.swing.JButton createButton​(int buttonType)
      Create a button with specified type.
      static javax.swing.JButton createButton​(java.lang.String text)
      Create a button with the given text.
      static javax.swing.JPanel createButtonPanel​(javax.swing.JButton[] buttons)
      Create the panel for the buttons; the button are aligned vertically; the side margins on the panel has a default value of 20.
      static javax.swing.JPanel createButtonPanel​(javax.swing.JButton[] buttons, char alignment)
      Create the panel for the buttons; the button are aligned as specified; the side margins on the panel has a default value of 20.
      static javax.swing.JPanel createButtonPanel​(javax.swing.JButton[] buttons, int sideMargin)
      Create the panel for the buttons; the button are aligned vertically; use sideMargin value for side margins on the panel.
      static javax.swing.JPanel createButtonPanel​(javax.swing.JButton[] buttons, int sideMargin, char alignment)
      Create the panel for the buttons; the button are aligned as specified; use sideMargin value for side margins on the panel, and use either X_AXIS or Y_AXIS as the alignment specification.
      static javax.swing.JButton createImageButton​(java.lang.String imageFile, java.lang.String alternateText, java.awt.Dimension preferredSize)
      Create an button that has an icon created from the given imageFile.
      static javax.swing.JButton createImageButton​(javax.swing.ImageIcon buttonIcon, java.lang.String alternateText, java.awt.Dimension preferredSize)
      Create a button with the given icon.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • X_AXIS

        public static final char X_AXIS
        layout the buttons on the panel created with createButtonPanel() horizontally along the X-axis
        See Also:
        Constant Field Values
      • Y_AXIS

        public static final char Y_AXIS
        layout the buttons on the panel created with createButtonPanel() vertically along the Y-axis
        See Also:
        Constant Field Values
      • ARROW_UP_TYPE

        public static final int ARROW_UP_TYPE
        Button that has an up arrow.
        See Also:
        Constant Field Values
      • ARROW_DOWN_TYPE

        public static final int ARROW_DOWN_TYPE
        Button that has a down arrow.
        See Also:
        Constant Field Values
      • BROWSE_TYPE

        public static final int BROWSE_TYPE
        Button that indicates a file chooser to browse.
        See Also:
        Constant Field Values
      • EDIT_TYPE

        public static final int EDIT_TYPE
        Button that indicates an edit operation.
        See Also:
        Constant Field Values
      • ARROW_LEFT_TYPE

        public static final int ARROW_LEFT_TYPE
        Button that has a left arrow.
        See Also:
        Constant Field Values
      • ARROW_RIGHT_TYPE

        public static final int ARROW_RIGHT_TYPE
        Button that has a right arrow.
        See Also:
        Constant Field Values
      • ARROW_SIZE

        public static final java.awt.Dimension ARROW_SIZE
        Dimension for the arrow button.
      • BROWSE_SIZE

        public static final java.awt.Dimension BROWSE_SIZE
        Dimension for the browse button.
      • BROWSE_ICON

        public static final javax.swing.Icon BROWSE_ICON
        Text for the browse button.
      • BROWSE_FONT

        public static final java.awt.Font BROWSE_FONT
        Font for the browse button label.
    • Method Detail

      • createButton

        public static javax.swing.JButton createButton​(int buttonType)
        Create a button with specified type.
        Parameters:
        buttonType - the type of button to create.
      • createButton

        public static javax.swing.JButton createButton​(java.lang.String text)
        Create a button with the given text.
        Parameters:
        text - the text to use in the button.
      • createButtonPanel

        public static javax.swing.JPanel createButtonPanel​(javax.swing.JButton[] buttons)
        Create the panel for the buttons; the button are aligned vertically; the side margins on the panel has a default value of 20.
        Parameters:
        buttons - the array of buttons to put in the panel.
      • createButtonPanel

        public static javax.swing.JPanel createButtonPanel​(javax.swing.JButton[] buttons,
                                                           char alignment)
        Create the panel for the buttons; the button are aligned as specified; the side margins on the panel has a default value of 20.
        Parameters:
        buttons - the array buttons to put in the panel.
        alignment - either X_AXIS or Y_AXIS
      • createButtonPanel

        public static javax.swing.JPanel createButtonPanel​(javax.swing.JButton[] buttons,
                                                           int sideMargin)
        Create the panel for the buttons; the button are aligned vertically; use sideMargin value for side margins on the panel.
        Parameters:
        buttons - the array buttons to put in the panel.
        sideMargin - the amount of margin space to use on the sides.
      • createButtonPanel

        public static javax.swing.JPanel createButtonPanel​(javax.swing.JButton[] buttons,
                                                           int sideMargin,
                                                           char alignment)
        Create the panel for the buttons; the button are aligned as specified; use sideMargin value for side margins on the panel, and use either X_AXIS or Y_AXIS as the alignment specification.
        Parameters:
        buttons - the array buttons to put in the panel.
        alignment - either X_AXIS or Y_AXIS
      • createImageButton

        public static javax.swing.JButton createImageButton​(java.lang.String imageFile,
                                                            java.lang.String alternateText,
                                                            java.awt.Dimension preferredSize)
        Create an button that has an icon created from the given imageFile.
        Parameters:
        imageFile - icon filename
        alternateText - text to use if the icon could not be loaded
        preferredSize - size that the button would like to be
        Returns:
        JButton new button
      • createImageButton

        public static javax.swing.JButton createImageButton​(javax.swing.ImageIcon buttonIcon,
                                                            java.lang.String alternateText,
                                                            java.awt.Dimension preferredSize)
        Create a button with the given icon.
        Parameters:
        buttonIcon - icon for the button
        alternateText - text to use if the icon could not be loaded
        preferredSize - size that the button would like to be
        Returns:
        JButton new button