Class ButtonBarLayout

  • All Implemented Interfaces:
    java.awt.LayoutManager, java.awt.LayoutManager2

    public class ButtonBarLayout
    extends java.lang.Object
    implements java.awt.LayoutManager2
    A layout manager for button bars. Makes all of the buttons the same size (the preferred size of the largest button). The buttons can be arranged in a single row or column and can be aligned with the leading or trailing edge of the container.
    • Field Detail

      • buttonGap

        protected final int buttonGap
      • orientation

        protected final int orientation
      • alignment

        protected final int alignment
    • Constructor Detail

      • ButtonBarLayout

        public ButtonBarLayout()
        Create a layout that puts the buttons in a left aligned horizontal row with a button gap of 5.
      • ButtonBarLayout

        public ButtonBarLayout​(int orientation,
                               int alignment)
        Create a layout with the specified alignment and orientation and a button gap of 5.
        Parameters:
        orientation - SwingConstants.HORIZONTAL or SwingConstants.VERTICAL
        alignment - SwingConstants.LEADING (for top or left) or SwingConstants.TRAILING (for bottom or right)
      • ButtonBarLayout

        public ButtonBarLayout​(int orientation,
                               int buttonGap,
                               int alignment)
        Parameters:
        orientation - SwingConstants.HORIZONTAL or SwingConstants.VERTICAL
        buttonGap - the spacing between buttons
        alignment - SwingConstants.LEADING (for top or left) or SwingConstants.TRAILING (for bottom or right)
    • Method Detail

      • vertical

        public static ButtonBarLayout vertical()
        Create a layout that puts the buttons in a top aligned vertical column with a button gap of 5.
      • rightAligned

        public static ButtonBarLayout rightAligned()
        Create a layout that puts the buttons in a right aligned horizontal row with a button gap of 5.
      • addLayoutComponent

        public void addLayoutComponent​(java.awt.Component comp,
                                       java.lang.Object constraints)
        Specified by:
        addLayoutComponent in interface java.awt.LayoutManager2
      • maximumLayoutSize

        public java.awt.Dimension maximumLayoutSize​(java.awt.Container target)
        Specified by:
        maximumLayoutSize in interface java.awt.LayoutManager2
      • getLayoutAlignmentX

        public float getLayoutAlignmentX​(java.awt.Container target)
        Specified by:
        getLayoutAlignmentX in interface java.awt.LayoutManager2
      • getLayoutAlignmentY

        public float getLayoutAlignmentY​(java.awt.Container target)
        Specified by:
        getLayoutAlignmentY in interface java.awt.LayoutManager2
      • invalidateLayout

        public void invalidateLayout​(java.awt.Container target)
        Specified by:
        invalidateLayout in interface java.awt.LayoutManager2
      • addLayoutComponent

        public void addLayoutComponent​(java.lang.String name,
                                       java.awt.Component comp)
        Specified by:
        addLayoutComponent in interface java.awt.LayoutManager
      • removeLayoutComponent

        public void removeLayoutComponent​(java.awt.Component comp)
        Specified by:
        removeLayoutComponent in interface java.awt.LayoutManager
      • preferredLayoutSize

        public java.awt.Dimension preferredLayoutSize​(java.awt.Container target)
        Specified by:
        preferredLayoutSize in interface java.awt.LayoutManager
      • minimumLayoutSize

        public java.awt.Dimension minimumLayoutSize​(java.awt.Container target)
        Specified by:
        minimumLayoutSize in interface java.awt.LayoutManager
      • layoutContainer

        public void layoutContainer​(java.awt.Container target)
        Specified by:
        layoutContainer in interface java.awt.LayoutManager