Package org.zkoss.zul

Class Box

All Implemented Interfaces:
Serializable, Cloneable, Component, Scope, ComponentCtrl
Direct Known Subclasses:
Hbox, Vbox

public class Box extends XulElement
A box.

Default getZclass(): z-vbox.(since 3.5.0)

Author:
tomyeh
See Also:
  • Constructor Details

    • Box

      public Box()
      Default: vertical (Vbox).
    • Box

      public Box(String orient)
      Parameters:
      orient - either "horizontal" or "vertical".
    • Box

      public Box(Component[] children)
      Constructor a box by assigning an array of children.
      Parameters:
      children - an array of children to be added
      Since:
      2.4.0
    • Box

      public Box(String orient, Component[] children)
      Constructor a box by assigning an array of children.
      Parameters:
      children - an array of children to be added
      Since:
      2.4.0
  • Method Details

    • isHorizontal

      public boolean isHorizontal()
      Returns whether it is a horizontal box.
      Since:
      3.0.0
    • isVertical

      public boolean isVertical()
      Returns whether it is a vertical box.
      Since:
      3.0.0
    • getOrient

      public String getOrient()
      Returns the orient (the same as AbstractComponent.getMold()).

      Default: "vertical".

    • setOrient

      public void setOrient(String orient) throws WrongValueException
      Sets the orient.
      Parameters:
      orient - either "horizontal" or "vertical".
      Throws:
      WrongValueException
    • getSpacing

      public String getSpacing()
      Returns the spacing between adjacent children, or null if the default spacing is used.

      The default spacing depends on the definition of the style class called "xxx-sp", where xxx is

      1. HtmlBasedComponent.getSclass() if it is not null.
      2. hbox if HtmlBasedComponent.getSclass() is null and it is a horizontal box.
      3. vbox if HtmlBasedComponent.getSclass() is null and it is a vertical box.

      Default: null (means to use the default spacing).

    • setSpacing

      public void setSpacing(String spacing)
      Sets the spacing between adjacent children.
      Parameters:
      spacing - the spacing (such as "0", "5px", "3pt" or "1em"). If null, empty ("") or "auto", the default spacing is used (i.e., controlled by CSS alone)
      See Also:
    • getAlign

      public String getAlign()
      Returns the alignment of cells of a box in the 'opposite' direction (null, start, center, end).

      Default: start

      The align attribute specifies how child elements of the box are aligned, when the size of the box is larger than the total size of the children. For boxes that have horizontal orientation, it specifies how its children will be aligned vertically. For boxes that have vertical orientation, it is used to specify how its children are aligned horizontally. The pack attribute (getPack()) is related to the alignment but is used to specify the position in the opposite direction.

      start
      Child elements are aligned starting from the left or top edge of the box. If the box is larger than the total size of the children, the extra space is placed on the right or bottom side.
      center
      Extra space is split equally along each side of the child elements, resulting in the children being placed in the center of the box.
      end
      Child elements are placed on the right or bottom edge of the box. If the box is larger than the total size of the children, the extra space is placed on the left or top side.
      stretch(since 5.0)
      Child elements are stretched to fill the box.
      Since:
      3.0.0
    • setAlign

      public void setAlign(String align)
      Sets the alignment of cells of this box in the 'opposite' direction (start, center, end, stretch).

      Refer to getAlign() for more information

      Parameters:
      align - the alignment in the 'opposite' direction. Allowed values: start, center, end, stretch. If empty or null, the browser's default is used (IE center and FF left, if vertical).
      Since:
      3.0.0
    • getPack

      public String getPack()
      Returns the pack alignment of cells of this box (start, center, end) plus an indication stretch option.

      Default: start.

      The pack attribute specifies where child elements of the box are placed when the box is larger that the size of the children. For boxes with horizontal orientation, it is used to indicate the position of children horizontally. For boxes with vertical orientation, it is used to indicate the position of children vertically. The align attribute (getAlign())is used to specify the position in the opposite direction.

      start
      Child elements are aligned starting from the left or top edge of the box. If the box is larger than the total size of the children, the Extra space is placed on the right or bottom side.
      center
      Extra space is split equally along each side of the child elements, resulting in the children being placed in the center of the box.
      end
      Child elements are placed on the right or bottom edge of the box. If the box is larger than the total size of the children, the extra space is placed on the left or top side.
      stretch(since 5.0)
      This is an extra option in addition to the (start, center, end) options. When add this extra option in the pack attribute, the Extra space is placed proportionally and evenly along each child elements. If you specify "stretch,start", then the Extra proportionally and evenly allocated space for each child is placed on the right or bottom side of the child. If you specify "stretch,center", then the Extra proportionally and evenly allocated space for each child is split equally along each side of the child. If you specify "stretch,end", then the Extra proportionally and evenly allocated space for each child is placed on the left or top side of the child. Note that if there are Splitter child inside this Box, then this Box behaves as if the pack attribute has been set the "stretch" option; no matter you really specify "stretch" in pack attribute or not. If you give null to the pack attribute, it is the same as "start". If simply give "stretch" to this pack attribute then it is the same as "stretch,start"
      Since:
      3.0.0
    • setPack

      public void setPack(String pack)
      Sets the alignment of cells of this box (start, center, end) plus an stretch option.
      Parameters:
      pack - the alignment. Allowed values: (start, center, end) plus an stretch option. If empty or null, it defaults to "start".
      Since:
      3.0.0
      See Also:
    • setSizedByContent

      public void setSizedByContent(boolean byContent)
      Sets whether sizing the cell's size by its content.

      Default: true. It means the cell's size is depended on its content.

      With Splitter, you can specify the sizedByContent to be false for resizing smoothly, if it contains a grid or other sophisticated components.

      Parameters:
      byContent -
      Since:
      5.0.4
    • isSizedByContent

      public boolean isSizedByContent()
      Returns whether sizing the cell's size by its content.

      Default: true.

      Since:
      5.0.4
      See Also:
    • evalCSSFlex

      public boolean evalCSSFlex()
      Description copied from class: HtmlBasedComponent
      Get whether css flex is enabled or not
      Overrides:
      evalCSSFlex in class HtmlBasedComponent
      Returns:
      css flex is enabled
    • renderProperties

      protected void renderProperties(ContentRenderer renderer) throws IOException
      Description copied from class: HtmlBasedComponent
      Renders the content of this component, excluding the enclosing tags and children.

      See also ZK Client-side Reference: Property Rendering

      Overrides:
      renderProperties in class XulElement
      Throws:
      IOException
    • getZclass

      public String getZclass()
      Description copied from class: HtmlBasedComponent
      Returns the ZK Cascading Style class for this component. It usually depends on the implementation of the mold (AbstractComponent.getMold()).

      Default: null (the default value depends on element).

      HtmlBasedComponent.setZclass(java.lang.String)) will completely replace the default style of a component. In other words, the default style of a component is associated with the default value of HtmlBasedComponent.getZclass(). Once it is changed, the default style won't be applied at all. If you want to perform small adjustments, use HtmlBasedComponent.setSclass(java.lang.String) instead.

      Overrides:
      getZclass in class HtmlBasedComponent
      See Also:
    • getPropertyAccess

      public PropertyAccess getPropertyAccess(String prop)
      Description copied from interface: ComponentCtrl
      Returns the corresponding property access object from the given property name, if any.
      Specified by:
      getPropertyAccess in interface ComponentCtrl
      Overrides:
      getPropertyAccess in class XulElement
      Parameters:
      prop - the name of the property
      Returns:
      null it means not to support for the property name.