Class RegionLayout


public class RegionLayout extends PageLayout<RegionLayout>
A layout with named regions similar to classic desktop BorderLayout.

RegionLayout provides a flexible structure with five named regions: north, south, east, west, and center. This pattern is familiar to Java Swing developers and works well for desktop-style application layouts.

Structure:

 ┌──────────────────────────────────────┐
 │               NORTH                  │
 ├────────┬─────────────────┬───────────┤
 │        │                 │           │
 │  WEST  │     CENTER      │   EAST    │
 │        │                 │           │
 │        │                 │           │
 ├────────┴─────────────────┴───────────┤
 │               SOUTH                  │
 └──────────────────────────────────────┘
 

Features:

  • Five named regions: north, south, east, west, center
  • Center region expands to fill available space
  • Configurable region sizes
  • Regions are optional - only shown when content is set
  • Uses VStack/HStack internally for reliable layout ordering

Usage:


 // Basic layout with all regions
 RegionLayout layout = new RegionLayout();
 layout.north(header)
       .west(navigation)
       .center(mainContent)
       .east(sidebar)
       .south(footer);

 // Minimal layout (header + content + footer)
 RegionLayout layout = new RegionLayout();
 layout.north(header)
       .center(content)
       .south(footer);

 // With custom sizes
 RegionLayout layout = new RegionLayout();
 layout.setWestWidth(280)
       .setEastWidth(300)
       .setNorthHeight(64)
       .setSouthHeight(48)
       .north(toolbar)
       .west(nav)
       .center(content);

 // Full viewport
 layout.fillViewport();
 
Since:
2025
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Constructor Details

    • RegionLayout

      public RegionLayout()
      Constructs a RegionLayout with default configuration.
  • Method Details

    • initialize

      protected void initialize()
      Builds the element tree for the layout.
      Overrides:
      initialize in class StyledElement<RegionLayout>
    • north

      public RegionLayout north(Element<?> content)
      Sets the north region content.
      Parameters:
      content - the north region content (header, toolbar, etc.)
      Returns:
      this RegionLayout for method chaining
    • south

      public RegionLayout south(Element<?> content)
      Sets the south region content.
      Parameters:
      content - the south region content (footer, status bar, etc.)
      Returns:
      this RegionLayout for method chaining
    • west

      public RegionLayout west(Element<?> content)
      Sets the west region content.
      Parameters:
      content - the west region content (navigation, sidebar, etc.)
      Returns:
      this RegionLayout for method chaining
    • east

      public RegionLayout east(Element<?> content)
      Sets the east region content.
      Parameters:
      content - the east region content (sidebar, properties panel, etc.)
      Returns:
      this RegionLayout for method chaining
    • center

      public RegionLayout center(Element<?> content)
      Sets the center region content.
      Parameters:
      content - the center region content (main content area)
      Returns:
      this RegionLayout for method chaining
    • setNorthHeight

      public RegionLayout setNorthHeight(int height)
      Sets the north region height.
      Parameters:
      height - the height in pixels
      Returns:
      this RegionLayout for method chaining
    • setNorthHeight

      public RegionLayout setNorthHeight(String height)
      Sets the north region height.
      Parameters:
      height - the height value (e.g., "64px", "auto")
      Returns:
      this RegionLayout for method chaining
    • setSouthHeight

      public RegionLayout setSouthHeight(int height)
      Sets the south region height.
      Parameters:
      height - the height in pixels
      Returns:
      this RegionLayout for method chaining
    • setSouthHeight

      public RegionLayout setSouthHeight(String height)
      Sets the south region height.
      Parameters:
      height - the height value (e.g., "48px", "auto")
      Returns:
      this RegionLayout for method chaining
    • setWestWidth

      public RegionLayout setWestWidth(int width)
      Sets the west region width.
      Parameters:
      width - the width in pixels
      Returns:
      this RegionLayout for method chaining
    • setWestWidth

      public RegionLayout setWestWidth(String width)
      Sets the west region width.
      Parameters:
      width - the width value (e.g., "280px", "20%")
      Returns:
      this RegionLayout for method chaining
    • setEastWidth

      public RegionLayout setEastWidth(int width)
      Sets the east region width.
      Parameters:
      width - the width in pixels
      Returns:
      this RegionLayout for method chaining
    • setEastWidth

      public RegionLayout setEastWidth(String width)
      Sets the east region width.
      Parameters:
      width - the width value (e.g., "300px", "25%")
      Returns:
      this RegionLayout for method chaining
    • setNorthBackground

      public RegionLayout setNorthBackground(String color)
      Sets the north region background color.
      Parameters:
      color - the background color
      Returns:
      this RegionLayout for method chaining
    • setSouthBackground

      public RegionLayout setSouthBackground(String color)
      Sets the south region background color.
      Parameters:
      color - the background color
      Returns:
      this RegionLayout for method chaining
    • setWestBackground

      public RegionLayout setWestBackground(String color)
      Sets the west region background color.
      Parameters:
      color - the background color
      Returns:
      this RegionLayout for method chaining
    • setEastBackground

      public RegionLayout setEastBackground(String color)
      Sets the east region background color.
      Parameters:
      color - the background color
      Returns:
      this RegionLayout for method chaining
    • setCenterBackground

      public RegionLayout setCenterBackground(String color)
      Sets the center region background color.
      Parameters:
      color - the background color
      Returns:
      this RegionLayout for method chaining
    • setNorthPadding

      public RegionLayout setNorthPadding(int padding)
      Sets padding for the north region.
      Parameters:
      padding - the padding in pixels
      Returns:
      this RegionLayout for method chaining
    • setNorthPadding

      public RegionLayout setNorthPadding(String padding)
      Sets padding for the north region.
      Parameters:
      padding - the padding value (e.g., "16px", "1rem")
      Returns:
      this RegionLayout for method chaining
    • setSouthPadding

      public RegionLayout setSouthPadding(int padding)
      Sets padding for the south region.
      Parameters:
      padding - the padding in pixels
      Returns:
      this RegionLayout for method chaining
    • setSouthPadding

      public RegionLayout setSouthPadding(String padding)
      Sets padding for the south region.
      Parameters:
      padding - the padding value (e.g., "16px", "1rem")
      Returns:
      this RegionLayout for method chaining
    • setWestPadding

      public RegionLayout setWestPadding(int padding)
      Sets padding for the west region.
      Parameters:
      padding - the padding in pixels
      Returns:
      this RegionLayout for method chaining
    • setWestPadding

      public RegionLayout setWestPadding(String padding)
      Sets padding for the west region.
      Parameters:
      padding - the padding value (e.g., "16px", "1rem")
      Returns:
      this RegionLayout for method chaining
    • setEastPadding

      public RegionLayout setEastPadding(int padding)
      Sets padding for the east region.
      Parameters:
      padding - the padding in pixels
      Returns:
      this RegionLayout for method chaining
    • setEastPadding

      public RegionLayout setEastPadding(String padding)
      Sets padding for the east region.
      Parameters:
      padding - the padding value (e.g., "16px", "1rem")
      Returns:
      this RegionLayout for method chaining
    • setCenterPadding

      public RegionLayout setCenterPadding(int padding)
      Sets padding for the center region.
      Parameters:
      padding - the padding in pixels
      Returns:
      this RegionLayout for method chaining
    • setCenterPadding

      public RegionLayout setCenterPadding(String padding)
      Sets padding for the center region.
      Parameters:
      padding - the padding value (e.g., "24px", "1.5rem")
      Returns:
      this RegionLayout for method chaining
    • getNorthRegion

      public Div getNorthRegion()
      Returns the north region for advanced customization.
      Returns:
      the north region div
    • getSouthRegion

      public Div getSouthRegion()
      Returns the south region for advanced customization.
      Returns:
      the south region div
    • getWestRegion

      public Div getWestRegion()
      Returns the west region for advanced customization.
      Returns:
      the west region div
    • getEastRegion

      public Div getEastRegion()
      Returns the east region for advanced customization.
      Returns:
      the east region div
    • getCenterRegion

      public Div getCenterRegion()
      Returns the center region for advanced customization.
      Returns:
      the center region div
    • getMiddleContainer

      public HStack getMiddleContainer()
      Returns the middle row container for advanced customization.
      Returns:
      the middle row HStack