Class SplitLayout


public class SplitLayout extends StyledElement<SplitLayout>
A two-pane layout with a fixed panel and a flexible main area.

SplitLayout creates common application layouts like sidebar navigation with main content, or master-detail views. One panel has a fixed size while the other expands to fill remaining space.

Layout Types:

  • Left sidebar with main content (default)
  • Right sidebar with main content
  • Top panel with main content
  • Bottom panel with main content

Usage:


 // Left sidebar layout (default)
 SplitLayout app = new SplitLayout(250);
 app.setSidebar(navigation);
 app.setMain(content);

 // Right sidebar layout
 SplitLayout rightSidebar = SplitLayout.rightSidebar(300);
 rightSidebar.setMain(content);
 rightSidebar.setSidebar(propertiesPanel);

 // Top/bottom split
 SplitLayout topBottom = SplitLayout.topPanel(100);
 topBottom.setSidebar(toolbar);
 topBottom.setMain(editor);

 // Full viewport height
 SplitLayout fullPage = new SplitLayout(280);
 fullPage.fillViewport();
 fullPage.setSidebar(sidebar);
 fullPage.setMain(mainContent);
 
Since:
2025
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • Constructor Details

    • SplitLayout

      public SplitLayout(int sidebarWidth)
      Constructs a left sidebar layout with the specified sidebar width.
      Parameters:
      sidebarWidth - the sidebar width in pixels
    • SplitLayout

      public SplitLayout(String sidebarWidth)
      Constructs a left sidebar layout with the specified sidebar width.
      Parameters:
      sidebarWidth - the sidebar width (e.g., "250px", "20%", "20rem")
  • Method Details

    • rightSidebar

      public static SplitLayout rightSidebar(int sidebarWidth)
      Creates a right sidebar layout with the specified sidebar width.
      Parameters:
      sidebarWidth - the sidebar width in pixels
      Returns:
      a new right sidebar SplitLayout
    • rightSidebar

      public static SplitLayout rightSidebar(String sidebarWidth)
      Creates a right sidebar layout with the specified sidebar width.
      Parameters:
      sidebarWidth - the sidebar width (e.g., "300px", "25%")
      Returns:
      a new right sidebar SplitLayout
    • topPanel

      public static SplitLayout topPanel(int panelHeight)
      Creates a top panel layout with the specified panel height.
      Parameters:
      panelHeight - the top panel height in pixels
      Returns:
      a new top panel SplitLayout
    • topPanel

      public static SplitLayout topPanel(String panelHeight)
      Creates a top panel layout with the specified panel height.
      Parameters:
      panelHeight - the top panel height (e.g., "64px", "4rem")
      Returns:
      a new top panel SplitLayout
    • bottomPanel

      public static SplitLayout bottomPanel(int panelHeight)
      Creates a bottom panel layout with the specified panel height.
      Parameters:
      panelHeight - the bottom panel height in pixels
      Returns:
      a new bottom panel SplitLayout
    • bottomPanel

      public static SplitLayout bottomPanel(String panelHeight)
      Creates a bottom panel layout with the specified panel height.
      Parameters:
      panelHeight - the bottom panel height (e.g., "200px", "30%")
      Returns:
      a new bottom panel SplitLayout
    • setSidebar

      public SplitLayout setSidebar(Element<?> content)
      Sets the content for the sidebar/fixed panel.
      Parameters:
      content - the element to display in the sidebar
      Returns:
      this SplitLayout for method chaining
    • setMain

      public SplitLayout setMain(Element<?> content)
      Sets the content for the main/flexible panel.
      Parameters:
      content - the element to display in the main area
      Returns:
      this SplitLayout for method chaining
    • getSidebarPane

      public StyledContainerElement<?> getSidebarPane()
      Returns the sidebar pane for direct styling or element addition.
      Returns:
      the sidebar pane element
    • getMainPane

      public StyledContainerElement<?> getMainPane()
      Returns the main pane for direct styling or element addition.
      Returns:
      the main pane element
    • setGap

      public SplitLayout setGap(int gap)
      Sets the gap between the sidebar and main panels.
      Overrides:
      setGap in class StyledElement<SplitLayout>
      Parameters:
      gap - the gap in pixels
      Returns:
      this SplitLayout for method chaining
    • setGap

      public SplitLayout setGap(String gap)
      Sets the gap between the sidebar and main panels.
      Overrides:
      setGap in class StyledElement<SplitLayout>
      Parameters:
      gap - the gap value (e.g., "1rem", "16px")
      Returns:
      this SplitLayout for method chaining
    • fillViewport

      public SplitLayout fillViewport()
      Sets the layout to fill the full viewport.
      Returns:
      this SplitLayout for method chaining
    • fillParent

      public SplitLayout fillParent()
      Sets the layout to fill its parent container.
      Returns:
      this SplitLayout for method chaining