Class VPanel


public class VPanel extends StyledElement<VPanel>
A vertical panel container that arranges elements in multiple rows with one cell each.

This container class extends CPanel to provide a table-based vertical layout where elements are distributed across multiple rows, each containing a single cell. Each row can have configurable height and content. Useful for creating vertical layouts like sidebars, navigation menus, or multi-row content areas.

Features:

  • Multi-row, single-cell vertical layout
  • Configurable cell heights (fixed, percentage, or auto)
  • Dynamic cell addition and removal
  • Automatic spacing between cells
  • Table-based structure for consistent layout

Usage:

 VPanel panel = new VPanel(3);  // 3 rows
 panel.setCellHeight(0, 100);   // First row 100px
 panel.setCellHeight(1, "auto");// Second row auto
 panel.setCellHeight(2, 200);   // Third row 200px
 panel.addElement(0, header);
 panel.addElement(1, content);
 panel.addElement(2, footer);
 
Since:
2007
Version:
1.0
Author:
Marvin P. Warble Jr.
See Also:
  • HPanel
  • CPanel
  • invalid reference
    VStack
  • Field Details

    • LAYOUT_FIXED

      public static final String LAYOUT_FIXED
      Fixed table layout mode - fixed width columns
      See Also:
    • LAYOUT_AUTO

      public static final String LAYOUT_AUTO
      Auto table layout mode - automatic column sizing
      See Also:
    • LAYOUT_INHERIT

      public static final String LAYOUT_INHERIT
      Inherited table layout mode - inherit from parent
      See Also:
  • Constructor Details

    • VPanel

      public VPanel()
      Creates a new VPanel with no cells.
    • VPanel

      public VPanel(int cells)
      Creates a new VPanel with the specified number of rows.
      Parameters:
      cells - The number of rows to create.
  • Method Details

    • setNumCells

      public final void setNumCells(int numCells)
      Sets the number of rows in this vertical panel, replacing any existing rows.
      Parameters:
      numCells - The number of rows to create.
    • setCellHeight

      public final void setCellHeight(int cellIndex, int height)
      Sets the height of a cell in pixels.
      Parameters:
      cellIndex - The zero-based index of the row.
      height - The height in pixels.
    • setCellHeight

      public final void setCellHeight(int cellIndex, String height)
      Sets the height of a cell using a CSS value.
      Parameters:
      cellIndex - The zero-based index of the row.
      height - The CSS height value (e.g., "100px", "50%", "auto").
    • addCell

      public int addCell()
      Adds a new row to the end of this vertical panel.
      Returns:
      The zero-based index of the newly added row.
    • addCells

      public void addCells(int numCells)
      Adds the specified number of new rows to the end of this vertical panel.
      Parameters:
      numCells - The number of rows to add.
    • addElement

      public Td addElement(int cellIndex, Element element)
      Adds an element to the specified row.
      Parameters:
      cellIndex - The zero-based index of the row.
      element - The element to add.
      Returns:
      The table cell containing the element, or null if the row does not exist.
    • getNumberOfCells

      public int getNumberOfCells()
    • setSpacing

      public final void setSpacing(int spacing)
    • addElement

      public final VPanel addElement(Element element)
      Description copied from class: Element
      Adds a child element to this element.

      The child is removed from its previous parent if it has one, then added to this element's children. If this element is already attached to a page, the child is also attached and registered for DOM addition.

      Overrides:
      addElement in class Element<T extends com.oorian.html.containers.CPanel<T>>
      Parameters:
      element - The child element to add.
      Returns:
      this element for method chaining
    • insertElement

      public final VPanel insertElement(int index, Element element)
      Description copied from class: Element
      Inserts a child element at the specified index.

      The child is removed from its previous parent if it has one, then inserted at the specified index in this element's children.

      Overrides:
      insertElement in class Element<T extends com.oorian.html.containers.CPanel<T>>
      Parameters:
      index - The index at which to insert the child.
      element - The child element to insert.
      Returns:
      this element for method chaining
    • getSpacing

      public final int getSpacing()
    • setWrapCellText

      public final void setWrapCellText(int cellIndex, boolean flag)
    • prewrite

      protected final void prewrite()
      Description copied from class: Element
      Hook method called before the element is written to output.

      Override this method to perform any last-minute configuration before rendering.

      Overrides:
      prewrite in class Element<T extends com.oorian.html.containers.CPanel<T>>
    • getHtml

      public void getHtml(StringBuilder buffer)
      Description copied from class: StyledElement
      Generates the HTML representation of this element, including state-based styles and interactive cursor attributes.
      Overrides:
      getHtml in class StyledElement<T extends com.oorian.html.containers.Panel<T>>
      Parameters:
      buffer - The StringBuilder to append the HTML output to.
    • setElement

      protected VPanel setElement(Element element)
      Replaces the content of this panel with the specified element.
      Overrides:
      setElement in class Element<T extends com.oorian.html.containers.Panel<T>>
      Parameters:
      element - The element to set as the sole content.
      Returns:
      This element for method chaining.
    • setVerticalAlign

      public StyledElement setVerticalAlign(VerticalAlign align)
      Sets the vertical alignment of content within this panel's content area.
      Overrides:
      setVerticalAlign in class StyledElement<T extends com.oorian.html.containers.Panel<T>>
      Parameters:
      align - The vertical alignment to apply.
      Returns:
      The content area element for method chaining.
    • hasElements

      public boolean hasElements()
      Description copied from class: Element
      Checks if this element has any child elements.
      Overrides:
      hasElements in class Element<T extends com.oorian.html.containers.Panel<T>>
      Returns:
      true if this element has children, false otherwise.
    • getElements

      public Elements getElements()
      Description copied from class: Element
      Returns the direct children of this element.
      Overrides:
      getElements in class Element<T extends com.oorian.html.containers.Panel<T>>
      Returns:
      A copy of the children collection.
    • getElement

      public Element getElement(int index)
      Description copied from class: Element
      Returns the child element at the specified index.
      Overrides:
      getElement in class Element<T extends com.oorian.html.containers.Panel<T>>
      Parameters:
      index - The zero-based index of the child.
      Returns:
      The child element, or null if index is out of bounds.
    • addText

      public final void addText(String text)
      Adds a text node to this panel.
      Overrides:
      addText in class Element<T extends com.oorian.html.containers.Panel<T>>
      Parameters:
      text - The text to add.
    • addText

      public final void addText(String text, String style)
      Adds styled text to this panel using a CSS style string.
      Overrides:
      addText in class Element<T extends com.oorian.html.containers.Panel<T>>
      Parameters:
      text - The text to add.
      style - The inline CSS style string.
    • addText

      public final void addText(String text, CssStyle style)
      Adds styled text to this panel using a CssStyle object.
      Overrides:
      addText in class Element<T extends com.oorian.html.containers.Panel<T>>
      Parameters:
      text - The text to add.
      style - The CssStyle to apply to the text.
    • setText

      public final void setText(String text)
      Sets the text content of this panel, replacing any existing content.
      Overrides:
      setText in class Element<T extends com.oorian.html.containers.Panel<T>>
      Parameters:
      text - The text to set. If null or empty, a non-breaking space is used.
    • setText

      public final void setText(String text, String style)
      Sets styled text content of this panel using a CSS style string, replacing any existing content.
      Overrides:
      setText in class Element<T extends com.oorian.html.containers.Panel<T>>
      Parameters:
      text - The text to set. If null or empty, a non-breaking space is used.
      style - The inline CSS style string.
    • setText

      public final void setText(String text, Font font)
      Sets styled text content of this panel using a Font, replacing any existing content.
      Overrides:
      setText in class Element<T extends com.oorian.html.containers.Panel<T>>
      Parameters:
      text - The text to set. If null or empty, a non-breaking space is used.
      font - The Font to apply to the text.
    • setText

      public final void setText(String text, CssStyle style)
      Sets styled text content of this panel using a CssStyle object, replacing any existing content.
      Overrides:
      setText in class Element<T extends com.oorian.html.containers.Panel<T>>
      Parameters:
      text - The text to set. If null or empty, a non-breaking space is used.
      style - The CssStyle to apply to the text.
    • initialize

      protected final void initialize()
      Description copied from class: Element
      Hook method called during element initialization.

      Override this method to set up the element's structure by adding child elements. This is called before Element.create() and only once during the element's lifecycle.

      Overrides:
      initialize in class StyledElement<T extends com.oorian.html.containers.Panel<T>>