Interface LayoutManager

  • All Known Implementing Classes:
    AbsoluteLayout, BorderLayout, GridLayout, LinearLayout, SplitPanel.ScrollPanelLayoutManager

    public interface LayoutManager
    A layout manager is a class that takes an area of usable space and a list of components to fit on that space. This is very similar to how AWT/Swing/SWT works. Lanterna contains a number of layout managers built-in that will arrange components in various ways, but you can also write your own. The typical way of providing customization and tuning, so the layout manager can distinguish between components and treat them in different ways, is to create a class and/or objects based on the LayoutData object, which can be assigned to each Component.
    See Also:
    AbsoluteLayout, BorderLayout, GridLayout, LinearLayout
    • Method Summary

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      void doLayout​(TerminalSize area, java.util.List<Component> components)
      Given a size constraint, update the location and size of each component in the component list by laying them out in the available area.
      TerminalSize getPreferredSize​(java.util.List<Component> components)
      This method returns the dimensions it would prefer to have to be able to layout all components while giving all of them as much space as they are asking for.
      boolean hasChanged()
      Returns true if the internal state of this LayoutManager has changed since the last call to doLayout.
    • Method Detail

      • getPreferredSize

        TerminalSize getPreferredSize​(java.util.List<Component> components)
        This method returns the dimensions it would prefer to have to be able to layout all components while giving all of them as much space as they are asking for.
        Parameters:
        components - List of components
        Returns:
        Size the layout manager would like to have
      • doLayout

        void doLayout​(TerminalSize area,
                      java.util.List<Component> components)
        Given a size constraint, update the location and size of each component in the component list by laying them out in the available area. This method will call setPosition(..) and setSize(..) on the Components.
        Parameters:
        area - Size available to this layout manager to lay out the components on
        components - List of components to lay out
      • hasChanged

        boolean hasChanged()
        Returns true if the internal state of this LayoutManager has changed since the last call to doLayout. This will tell the container that it needs to call doLayout again.
        Returns:
        true if this layout manager's internal state has changed since the last call to doLayout