Class VerticalFlowLayout

java.lang.Object
edu.cnu.mdi.component.VerticalFlowLayout
All Implemented Interfaces:
LayoutManager, LayoutManager2, Serializable

public class VerticalFlowLayout extends Object implements LayoutManager2, Serializable
See Also:
  • Field Details

  • Constructor Details

    • VerticalFlowLayout

      public VerticalFlowLayout()
      Constructs a new VerticalFlowLayout.
    • VerticalFlowLayout

      public VerticalFlowLayout(boolean uniformWidths, int vGap)
      Constructs a new VerticalFlowLayout with your own width sizing type and vertical gap values.
      Parameters:
      uniformWidths - size the widths of the component to be uniform or not
      vGap - vertical gap
  • Method Details

    • addLayoutComponent

      public void addLayoutComponent(String name, Component comp)
      Adds the specified component to the layout.
      Specified by:
      addLayoutComponent in interface LayoutManager
      Parameters:
      name - this is ignored
      comp - the component to be added
      Throws:
      IllegalArgumentException - Invalid component or constraint.
    • removeLayoutComponent

      public void removeLayoutComponent(Component comp)
      Remove the specified component.
      Specified by:
      removeLayoutComponent in interface LayoutManager
      Parameters:
      comp - the component to be removed
      Throws:
      IllegalArgumentException - Invalid component.
    • minimumLayoutSize

      public Dimension minimumLayoutSize(Container parent)
      Gets the minimum dimensions needed to lay out the component contained in the specified target container.

      Computed the same way as preferredLayoutSize(java.awt.Container), but using each component's minimum size instead of its preferred size.

      Specified by:
      minimumLayoutSize in interface LayoutManager
      Parameters:
      parent - the Container on which to do the layout
      Returns:
      minimum layout size
      See Also:
    • preferredLayoutSize

      public Dimension preferredLayoutSize(Container parent)
      Gets the preferred dimensions for this layout given the components in the specified target container.
      • For the horizontal size, this will go through all of the components and get the widest one and add the external and internal horizontal paddings.
      • For the vertical size, this will add up the heights of all of the components and add in the internal and external vertical paddings.
      Specified by:
      preferredLayoutSize in interface LayoutManager
      Parameters:
      parent - the Container on which to do the layout
      Returns:
      preferred preferred layout size
      See Also:
    • layoutContainer

      public void layoutContainer(Container parent)
      Layout the components within the specified container
      Specified by:
      layoutContainer in interface LayoutManager
      Parameters:
      parent - the container that is being layed out
      See Also:
    • addLayoutComponent

      public void addLayoutComponent(Component comp, Object constraints)
      Adds the specified component to the layout, using the specified constraint object.
      Specified by:
      addLayoutComponent in interface LayoutManager2
      Parameters:
      comp - the component to be added
      constraints - where/how the component is added to the layout.
    • maximumLayoutSize

      public Dimension maximumLayoutSize(Container target)
      Returns the maximum size of this component.
      Specified by:
      maximumLayoutSize in interface LayoutManager2
      See Also:
    • getLayoutAlignmentX

      public float getLayoutAlignmentX(Container target)
      Returns the alignment along the x axis. This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc.
      Specified by:
      getLayoutAlignmentX in interface LayoutManager2
    • getLayoutAlignmentY

      public float getLayoutAlignmentY(Container target)
      Returns the alignment along the y axis. This specifies how the component would like to be aligned relative to other components. The value should be a number between 0 and 1 where 0 represents alignment along the origin, 1 is aligned the furthest away from the origin, 0.5 is centered, etc.
      Specified by:
      getLayoutAlignmentY in interface LayoutManager2
    • invalidateLayout

      public void invalidateLayout(Container target)
      Invalidates the layout, indicating that if the layout manager has cached information it should be discarded.
      Specified by:
      invalidateLayout in interface LayoutManager2
    • areWidthsUniform

      public boolean areWidthsUniform()
      See if the widths are set to uniform.
      Returns:
      uniform width flag
    • getVerticalGap

      public int getVerticalGap()
      Get the vertical gap value.
      Returns:
      vertical gap
    • getExternalPadLeft

      public int getExternalPadLeft()
      Returns the left external horizontal padding. This is the space between the widest component in the column and the left edge.
      Returns:
      Left external horizontal padding.
    • getExternalPadRight

      public int getExternalPadRight()
      Returns the right external horizontal padding. This is the space between the widest component in the column and the left right edge.
      Returns:
      Right external horizontal padding.
    • getExternalPadTop

      public int getExternalPadTop()
      Returns the top external vertical padding. This is the space between the top component and the top edge.
      Returns:
      Top external vertical padding.
    • getExternalPadBottom

      public int getExternalPadBottom()
      Returns the bottom external vertical padding. This is the space between the bottom component and the bottom edge.
      Returns:
      Bottom external vertical padding.
    • getInternalPadX

      public int getInternalPadX()
      Get the internal horizontal padding. This is a simple way to grow the horizontal preferred size of all of the components by a certain amount. It works great on buttons, because their preferred size is usually not wide enough to look good.
      Returns:
      internal horizontal padding
    • getInternalPadY

      public int getInternalPadY()
      Get the internal vertical padding. This is a simple way to grow the vertical preferred size of all of the components by a certain amount. It works great on buttons, because their preferred size is usually too short.
      Returns:
      internal vertical padding
    • setUniformWidths

      public void setUniformWidths(boolean uniformWidths)
      Set the uniform width flag. If you set this to true, the alignment value is ignored.
      Parameters:
      uniformWidths -
      • true = make all the widths uniform (sizing to match the widest)
      • false = let all components take their various preferred widths
    • setVerticalGap

      public void setVerticalGap(int vGap)
      Set the vertical gap value.
      Parameters:
      vGap - vertical gap
    • setExternalPadLeft

      public void setExternalPadLeft(int padding)
      Set the left external horizontal padding. This is the space between the widest component in the column and the edge.
      Parameters:
      padding - the amount of padding in pixels.
    • setExternalPadRight

      public void setExternalPadRight(int padding)
      Set the right external horizontal padding. This is the space between the widest component in the column and the edge.
      Parameters:
      padding - the amount of padding in pixels.
    • setExternalPadTop

      public void setExternalPadTop(int padding)
      Set the top external vertical padding. This is the space between the top and the top edge.
      Parameters:
      padding - the amount of padding in pixels.
    • setExternalPadBottom

      public void setExternalPadBottom(int padding)
      Set the bottom external vertical padding. This is the space between the bottom and the bottom edge.
      Parameters:
      padding - the amount of padding in pixels.
    • setInternalPadX

      public void setInternalPadX(int padding)
      Set the internal horizontal padding. This is a simple way to grow the horizontal preferred size of all of the components by a certain amount. It works great on buttons, because their preferred size is usually not wide enough to look good.
      Parameters:
      padding - internal horizontal padding
    • setInternalPadY

      public void setInternalPadY(int padding)
      Set the internal vertical padding. This is a simple way to grow the vertical preferred size of all of the components by a certain amount. It works great on buttons, because their preferred size is usually too short.
      Parameters:
      padding - internal vertical padding