Class FormatLayout

  • All Implemented Interfaces:
    java.awt.LayoutManager, java.io.Serializable

    public class FormatLayout
    extends java.lang.Object
    implements java.awt.LayoutManager, java.io.Serializable
    A layout manager that spaces components over six columns in seven different formats.
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      static int C
      A useful constant representing layout format 1.
      private int[] columnGaps
      The gaps between the columns (gap[0] is the gap following column zero).
      private int columns0to5Width
      Combined width of columns 0 to 5.
      private int columns1and2Width
      Combined width of columns 1 and 2.
      private int columns1to4Width
      Combined width of columns 1 to 4.
      private int columns1to5Width
      Combined width of columns 1 to 5.
      private int columns4and5Width
      Combined width of columns 4 and 5.
      private int[] columnWidths
      Working array for recording the width of each column.
      static int LC
      A useful constant representing layout format 2.
      static int LCB
      A useful constant representing layout format 3.
      static int LCBLC
      A useful constant representing layout format 6.
      static int LCBLCB
      A useful constant representing layout format 7.
      static int LCLC
      A useful constant representing layout format 4.
      static int LCLCB
      A useful constant representing layout format 5.
      private int[] rowFormats
      The layout format for each row.
      private int rowGap
      The gap between the rows.
      private int[] rowHeights
      Working array for recording the height of each row.
      private static long serialVersionUID
      For serialization.
      private int totalHeight
      The total height of the layout.
      private int totalWidth
      The total width of the layout.
    • Constructor Summary

      Constructors 
      Constructor Description
      FormatLayout​(int rowCount, int[] rowFormats)
      Constructs a new layout manager that can be used to create input forms.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void addLayoutComponent​(java.awt.Component comp)
      Not used.
      void addLayoutComponent​(java.lang.String name, java.awt.Component comp)
      Not used.
      void complete()
      Finishes of the processing.
      void layoutContainer​(java.awt.Container parent)
      Performs the layout of the container.
      java.awt.Dimension minimumLayoutSize​(java.awt.Container parent)
      Returns the minimum size of the component using this layout manager.
      java.awt.Dimension preferredLayoutSize​(java.awt.Container parent)
      Returns the preferred size of the component using this layout manager.
      void removeLayoutComponent​(java.awt.Component comp)
      Not used.
      void removeLayoutComponent​(java.lang.String name, java.awt.Component comp)
      Not used.
      private boolean splitLayout()
      Returns true if this layout involves a split into two sections.
      protected void updateC​(int rowIndex, java.awt.Dimension d0)
      Processes a row in 'C' format.
      protected void updateLC​(int rowIndex, java.awt.Dimension d0, java.awt.Dimension d1)
      Processes a row in 'LC' format.
      protected void updateLCB​(int rowIndex, java.awt.Dimension d0, java.awt.Dimension d1, java.awt.Dimension d2)
      Processes a row in 'LCB' format.
      protected void updateLCBLC​(int rowIndex, java.awt.Dimension d0, java.awt.Dimension d1, java.awt.Dimension d2, java.awt.Dimension d3, java.awt.Dimension d4)
      Processes a row in 'LCBLC' format.
      protected void updateLCBLCB​(int rowIndex, java.awt.Dimension d0, java.awt.Dimension d1, java.awt.Dimension d2, java.awt.Dimension d3, java.awt.Dimension d4, java.awt.Dimension d5)
      Processes a row in 'LCBLCB' format.
      protected void updateLCLC​(int rowIndex, java.awt.Dimension d0, java.awt.Dimension d1, java.awt.Dimension d2, java.awt.Dimension d3)
      Processes a row in 'LCLC' format.
      protected void updateLCLCB​(int rowIndex, java.awt.Dimension d0, java.awt.Dimension d1, java.awt.Dimension d2, java.awt.Dimension d3, java.awt.Dimension d4)
      Processes a row in 'LCLCB' format.
      • Methods inherited from class java.lang.Object

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

      • serialVersionUID

        private static final long serialVersionUID
        For serialization.
        See Also:
        Constant Field Values
      • C

        public static final int C
        A useful constant representing layout format 1.
        See Also:
        Constant Field Values
      • LC

        public static final int LC
        A useful constant representing layout format 2.
        See Also:
        Constant Field Values
      • LCB

        public static final int LCB
        A useful constant representing layout format 3.
        See Also:
        Constant Field Values
      • LCLC

        public static final int LCLC
        A useful constant representing layout format 4.
        See Also:
        Constant Field Values
      • LCLCB

        public static final int LCLCB
        A useful constant representing layout format 5.
        See Also:
        Constant Field Values
      • LCBLC

        public static final int LCBLC
        A useful constant representing layout format 6.
        See Also:
        Constant Field Values
      • LCBLCB

        public static final int LCBLCB
        A useful constant representing layout format 7.
        See Also:
        Constant Field Values
      • rowFormats

        private int[] rowFormats
        The layout format for each row.
      • rowGap

        private int rowGap
        The gap between the rows.
      • columnGaps

        private int[] columnGaps
        The gaps between the columns (gap[0] is the gap following column zero).
      • rowHeights

        private int[] rowHeights
        Working array for recording the height of each row.
      • totalHeight

        private int totalHeight
        The total height of the layout.
      • columnWidths

        private int[] columnWidths
        Working array for recording the width of each column.
      • totalWidth

        private int totalWidth
        The total width of the layout.
      • columns1and2Width

        private int columns1and2Width
        Combined width of columns 1 and 2.
      • columns4and5Width

        private int columns4and5Width
        Combined width of columns 4 and 5.
      • columns1to4Width

        private int columns1to4Width
        Combined width of columns 1 to 4.
      • columns1to5Width

        private int columns1to5Width
        Combined width of columns 1 to 5.
      • columns0to5Width

        private int columns0to5Width
        Combined width of columns 0 to 5.
    • Constructor Detail

      • FormatLayout

        public FormatLayout​(int rowCount,
                            int[] rowFormats)
        Constructs a new layout manager that can be used to create input forms. The layout manager works by arranging components in rows using six columns (some components will use more than one column).

        Any component can be added, but I think of them in terms of Labels, Components, and Buttons. The formats available are: C, LC, LCB, LCLC, LCLCB, LCBLC or LCBLCB.

        C 1 component in this row (spread across all six columns).
        LC 2 components, a label in the 1st column, and a component using the remaining 5 columns).
        LCB 3 components, a label in the 1st column, a component spread across the next 4, and a button in the last column.
        LCLC 4 components, a label in column 1, a component in 2-3, a label in 4 and a component in 5-6.
        LCLCB 5 components, a label in column 1, a component in 2-3, a label in 4, a component in 5 and a button in 6.
        LCBLC 5 components, a label in column 1, a component in 2, a button in 3, a label in 4, a component in 5-6.
        LCBLCB 6 components, one in each column.

        Columns 1 and 4 expand to accommodate the widest label, and 3 and 6 to accommodate the widest button.

        Each row will contain the number of components indicated by the format. Be sure to specify enough row formats to cover all the components you add to the layout.

        Parameters:
        rowCount - the number of rows.
        rowFormats - the row formats.
    • Method Detail

      • preferredLayoutSize

        public java.awt.Dimension preferredLayoutSize​(java.awt.Container parent)
        Returns the preferred size of the component using this layout manager.
        Specified by:
        preferredLayoutSize in interface java.awt.LayoutManager
        Parameters:
        parent - the parent.
        Returns:
        the preferred size of the component.
      • minimumLayoutSize

        public java.awt.Dimension minimumLayoutSize​(java.awt.Container parent)
        Returns the minimum size of the component using this layout manager.
        Specified by:
        minimumLayoutSize in interface java.awt.LayoutManager
        Parameters:
        parent - the parent.
        Returns:
        the minimum size of the component
      • layoutContainer

        public void layoutContainer​(java.awt.Container parent)
        Performs the layout of the container.
        Specified by:
        layoutContainer in interface java.awt.LayoutManager
        Parameters:
        parent - the parent.
      • updateC

        protected void updateC​(int rowIndex,
                               java.awt.Dimension d0)
        Processes a row in 'C' format.
        Parameters:
        rowIndex - the row index.
        d0 - dimension 0.
      • updateLC

        protected void updateLC​(int rowIndex,
                                java.awt.Dimension d0,
                                java.awt.Dimension d1)
        Processes a row in 'LC' format.
        Parameters:
        rowIndex - the row index.
        d0 - dimension 0.
        d1 - dimension 1.
      • updateLCB

        protected void updateLCB​(int rowIndex,
                                 java.awt.Dimension d0,
                                 java.awt.Dimension d1,
                                 java.awt.Dimension d2)
        Processes a row in 'LCB' format.
        Parameters:
        rowIndex - the row index.
        d0 - dimension 0.
        d1 - dimension 1.
        d2 - dimension 2.
      • updateLCLC

        protected void updateLCLC​(int rowIndex,
                                  java.awt.Dimension d0,
                                  java.awt.Dimension d1,
                                  java.awt.Dimension d2,
                                  java.awt.Dimension d3)
        Processes a row in 'LCLC' format.
        Parameters:
        rowIndex - the row index.
        d0 - dimension 0.
        d1 - dimension 1.
        d2 - dimension 2.
        d3 - dimension 3.
      • updateLCBLC

        protected void updateLCBLC​(int rowIndex,
                                   java.awt.Dimension d0,
                                   java.awt.Dimension d1,
                                   java.awt.Dimension d2,
                                   java.awt.Dimension d3,
                                   java.awt.Dimension d4)
        Processes a row in 'LCBLC' format.
        Parameters:
        rowIndex - the row index.
        d0 - dimension 0.
        d1 - dimension 1.
        d2 - dimension 2.
        d3 - dimension 3.
        d4 - dimension 4.
      • updateLCLCB

        protected void updateLCLCB​(int rowIndex,
                                   java.awt.Dimension d0,
                                   java.awt.Dimension d1,
                                   java.awt.Dimension d2,
                                   java.awt.Dimension d3,
                                   java.awt.Dimension d4)
        Processes a row in 'LCLCB' format.
        Parameters:
        rowIndex - the row index.
        d0 - dimension 0.
        d1 - dimension 1.
        d2 - dimension 2.
        d3 - dimension 3.
        d4 - dimension 4.
      • updateLCBLCB

        protected void updateLCBLCB​(int rowIndex,
                                    java.awt.Dimension d0,
                                    java.awt.Dimension d1,
                                    java.awt.Dimension d2,
                                    java.awt.Dimension d3,
                                    java.awt.Dimension d4,
                                    java.awt.Dimension d5)
        Processes a row in 'LCBLCB' format.
        Parameters:
        rowIndex - the row index.
        d0 - dimension 0.
        d1 - dimension 1.
        d2 - dimension 2.
        d3 - dimension 3.
        d4 - dimension 4.
        d5 - dimension 5.
      • complete

        public void complete()
        Finishes of the processing.
      • splitLayout

        private boolean splitLayout()
        Returns true if this layout involves a split into two sections.
        Returns:
        true if this layout involves a split into two sections.
      • addLayoutComponent

        public void addLayoutComponent​(java.awt.Component comp)
        Not used.
        Parameters:
        comp - the component.
      • removeLayoutComponent

        public void removeLayoutComponent​(java.awt.Component comp)
        Not used.
        Specified by:
        removeLayoutComponent in interface java.awt.LayoutManager
        Parameters:
        comp - the component.
      • addLayoutComponent

        public void addLayoutComponent​(java.lang.String name,
                                       java.awt.Component comp)
        Not used.
        Specified by:
        addLayoutComponent in interface java.awt.LayoutManager
        Parameters:
        name - the component name.
        comp - the component.
      • removeLayoutComponent

        public void removeLayoutComponent​(java.lang.String name,
                                          java.awt.Component comp)
        Not used.
        Parameters:
        name - the component name.
        comp - the component.