Package swingtree.api

Interface Layout

All Known Implementing Classes:
Layout.BorderLayoutInstaller, Layout.ForBoxLayout, Layout.ForFlowLayout, Layout.ForMigLayout, Layout.GridLayoutInstaller, Layout.None, Layout.Unspecific

@Immutable public interface Layout
An abstract representation of an immutable layout configuration for a specific component, for which layout manager specific implementations can be instantiated through various factory methods like border(), flow(), grid(int, int)... and then supplied to the style API through ComponentStyleDelegate.layout(Layout) so that the layout can then be installed onto a component dynamically.

The various layout types hold necessary information and implementation logic required for installing the layout onto a component through the installFor(JComponent) method, which will be used by the style engine of SwingTree every time the layout object state changes compared to the previous state effectively making the layout mechanics of a component fully dynamic.

You may implement this interface to create custom layout configurations for other kinds of LayoutManager implementations.

This interface also contains various implementations for supporting the most common types of LayoutManagers.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static final class 
    The Layout.BorderLayoutInstaller layout is a layout that represents a BorderLayout layout configuration for a component, which consists of the horizontal gap and vertical gap.
    static final class 
    The Layout.ForBoxLayout layout is a layout that represents a BoxLayout layout configuration for a component, which consists of the axis.
    static final class 
    The Layout.ForFlowLayout layout is a layout that represents a FlowLayout layout configuration for a component.
    static final class 
    The Layout.ForMigLayout layout is a layout that represents a MigLayout layout configuration for a component.
    static final class 
    The Layout.GridLayoutInstaller layout is a layout that represents a GridLayout layout configuration for a component, which consists of the number of rows, number of columns, horizontal gap and vertical gap.
    static final class 
    The Layout.None layout is a layout that represents the absence of a LayoutManager for a component.
    static final class 
    The Layout.Unspecific layout is a layout that represents the lack of a specific layout being set for a component.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Layout
    A factory method for creating a layout that installs the BorderLayout onto a component based on the supplied parameters.
    static Layout
    border(int horizontalGap, int verticalGap)
    A factory method for creating a layout that installs the BorderLayout onto a component based on the supplied parameters.
    static Layout
    box()
    A factory method for creating a layout that installs the BoxLayout onto a component with a default axis of UI.Axis.X.
    static Layout
    box(UI.Axis axis)
    A factory method for creating a layout that installs the BoxLayout onto a component based on the supplied UI.Axis parameter.
    boolean
     
    static Layout
    Creates a layout that installs the FlowLayout with a default alignment of UI.HorizontalAlignment.CENTER and a default gap of 5 pixels.
    static Layout
    A factory method for creating a layout that installs the FlowLayout onto a component based on the supplied parameters.
    static Layout
    flow(UI.HorizontalAlignment align, int hgap, int vgap)
    A factory method for creating a layout that installs the FlowLayout onto a component based on the supplied parameters.
    static Layout
    grid(int rows, int cols)
    A factory method for creating a layout that installs the GridLayout onto a component based on the supplied parameters.
    static Layout
    grid(int rows, int cols, int horizontalGap, int verticalGap)
    A factory method for creating a layout that installs the GridLayout onto a component based on the supplied parameters.
    int
     
    void
    Installs this layout for the supplied component.
    static Layout
    mig(String constr)
    A factory method for creating a layout that installs the MigLayout manager onto a component based on the supplied parameters.
    static Layout
    mig(String constr, String rowConstr)
    A factory method for creating a layout that installs the MigLayout manager onto a component based on the supplied parameters.
    static Layout
    mig(String constr, String colConstr, String rowConstr)
    This leads to the installation of the MigLayout layout manager, which is a powerful general purpose layout manager for Swing.
    static Layout
    If you don't want to assign any layout to a component style, but you also don't want to pass null to the ComponentStyleDelegate.layout(Layout) method, you can use the no-op instance returned by this method.
    static Layout
    A factory method for creating a layout that does nothing (i.e.
  • Method Details

    • hashCode

      int hashCode()
      Overrides:
      hashCode in class Object
      Returns:
      A hash code value for this layout.
    • equals

      boolean equals(Object o)
      Overrides:
      equals in class Object
      Parameters:
      o - The object to compare this layout to.
      Returns:
      true if the supplied object is a layout that is equal to this layout, false otherwise.
    • installFor

      void installFor(JComponent component)
      Installs this layout for the supplied component.
      Parameters:
      component - The component to install this layout for.
    • unspecific

      static Layout unspecific()
      A factory method for creating a layout that does nothing (i.e. it does not install any layout for a component). This is a no-op layout that can be used to represent the lack of a specific layout being set for a component without having to set the layout to null.
      Returns:
      A layout that does nothing, i.e. it does not install any layout for a component.
    • none

      static Layout none()
      If you don't want to assign any layout to a component style, but you also don't want to pass null to the ComponentStyleDelegate.layout(Layout) method, you can use the no-op instance returned by this method.
      Returns:
      A layout that removes any existing layout from a component.
    • mig

      static Layout mig(String constr, String colConstr, String rowConstr)
      This leads to the installation of the MigLayout layout manager, which is a powerful general purpose layout manager for Swing. Click here for more information.
      Parameters:
      constr - The layout constraints for the layout.
      rowConstr - The row constraints for the layout.
      colConstr - The column constraints for the layout.
      Returns:
      A layout that uses the MigLayout.
    • mig

      static Layout mig(String constr, String rowConstr)
      A factory method for creating a layout that installs the MigLayout manager onto a component based on the supplied parameters. The MigLayout layout manager is a powerful general purpose layout manager for Swing. Click here for more information.
      Parameters:
      constr - The layout constraints for the layout.
      rowConstr - The row constraints for the layout.
      Returns:
      A layout that uses the MigLayout.
    • mig

      static Layout mig(String constr)
      A factory method for creating a layout that installs the MigLayout manager onto a component based on the supplied parameters. This will effectively translate to a call to the MigLayout(String) constructor with the supplied constraints. In case you are not familiar with the MigLayout constraints, you can find more information about them here.
      Parameters:
      constr - The layout constraints for the layout.
      Returns:
      A layout that uses the MigLayout.
    • flow

      static Layout flow(UI.HorizontalAlignment align, int hgap, int vgap)
      A factory method for creating a layout that installs the FlowLayout onto a component based on the supplied parameters.
      Parameters:
      align - The alignment for the layout, which has to be one of
      hgap - The horizontal gap for the layout.
      vgap - The vertical gap for the layout.
      Returns:
      A layout that installs the FlowLayout onto a component.
    • flow

      static Layout flow(UI.HorizontalAlignment align)
      A factory method for creating a layout that installs the FlowLayout onto a component based on the supplied parameters.
      Parameters:
      align - The alignment for the layout, which has to be one of
      Returns:
      A layout that installs the FlowLayout onto a component.
    • flow

      static Layout flow()
      Creates a layout that installs the FlowLayout with a default alignment of UI.HorizontalAlignment.CENTER and a default gap of 5 pixels.
      Returns:
      A layout that installs the FlowLayout onto a component.
    • border

      static Layout border(int horizontalGap, int verticalGap)
      A factory method for creating a layout that installs the BorderLayout onto a component based on the supplied parameters.
      Parameters:
      horizontalGap - The horizontal gap for the layout.
      verticalGap - The vertical gap for the layout.
      Returns:
      A layout that installs the BorderLayout onto a component.
    • border

      static Layout border()
      A factory method for creating a layout that installs the BorderLayout onto a component based on the supplied parameters. The installed layout will have a default gap of 0 pixels.
      Returns:
      A layout that installs the BorderLayout onto a component.
    • grid

      static Layout grid(int rows, int cols, int horizontalGap, int verticalGap)
      A factory method for creating a layout that installs the GridLayout onto a component based on the supplied parameters.
      Parameters:
      rows - The number of rows for the layout.
      cols - The number of columns for the layout.
      horizontalGap - The horizontal gap for the layout.
      verticalGap - The vertical gap for the layout.
      Returns:
      A layout that installs the GridLayout onto a component.
    • grid

      static Layout grid(int rows, int cols)
      A factory method for creating a layout that installs the GridLayout onto a component based on the supplied parameters. The installed layout will have a default gap of 0 pixels.
      Parameters:
      rows - The number of rows for the layout.
      cols - The number of columns for the layout.
      Returns:
      A layout that installs the GridLayout onto a component.
    • box

      static Layout box(UI.Axis axis)
      A factory method for creating a layout that installs the BoxLayout onto a component based on the supplied UI.Axis parameter. The axis determines whether the layout will be a horizontal or vertical BoxLayout.
      Parameters:
      axis - The axis for the layout, which has to be one of
      Returns:
      A layout that installs the BoxLayout onto a component.
    • box

      static Layout box()
      A factory method for creating a layout that installs the BoxLayout onto a component with a default axis of UI.Axis.X.
      Returns:
      A layout that installs the default BoxLayout onto a component.