- Size types
- Content-dependent size
-
The component will take enough space to fit its content.
Examples:
-
For Label, the size is defined by text length.
-
For containers, the size is defined by the sum of all component sizes inside a container.
XML<label width=”AUTO”/>
Javalabel.setWidth(Component.AUTO_SIZE);
Components with content-dependent size will adjust their dimensions during screen layout initialization or when the content size is changed.
-
- Fixed size
- Relative size
- Container specifics
-
By default, containers without the expand attribute provide equal space for all nested components. Exceptions: flowBox and htmlBox.
For example:
link:../../../../../source/cookbook/screen_layout_rules_container.xml[role=include]
Components and containers width and height are content-dependent by default. Some containers have different default dimensions:
Container Width Height 100%
AUTO
100%
AUTO
100%
AUTO
The root layout element is a vertical container (
VBox
), which has 100% width and height. The height can beAUTO
in dialog mode.Tabs within a TabSheet are VBox containers.
GroupBox
component contains aVBox
or anHBox
, depending on the orientation property value.Example of a container with content-based size:
link:../../../../../source/cookbook/screen_layout_rules_container_2.xml[role=include]
Example of a container with relative size:
link:../../../../../source/cookbook/screen_layout_rules_container_3.xml[role=include]
Here,
layout
, as well asvbox
orhbox
, provides equal space to all nested components, andgroupBox
has 100% height. In addition to that,groupBox
has 100% width by default and takes all the available space.
- Component specifics
-
It is recommended to set the absolute or relative height for Table and Tree. Otherwise, a table/tree can take unlimited size, if there are too many rows or nodes.
ScrollBox must have fixed or relative (but not AUTO) width and height. Components inside
ScrollBox
, positioned in the scrolling direction, may not have relative dimensions.The following examples show the correct use of horizontal and vertical
ScrollBox
containers. If scrolling is required in both directions, bothheight
andwidth
must be set for the components (AUTO or absolute).
- The expand option
-
The container’s expand attribute allows specifying the component that will be given maximum available space.
The component specified in
expand
will have 100% size in the direction of the component expansion (vertically - forVBox
, horizontally - forHBox
). When container size is changed, the component will change its size accordingly.link:../../../../../source/cookbook/screen_layout_rules_expand.xml[role=include]
expand
works relatively to component expansion, for example:link:../../../../../source/cookbook/screen_layout_rules_expand_2.xml[role=include]
In the following example, the auxiliary Label element (spacer) is used. Due to applied
expand
, it takes all the space left in the container.link:../../../../../source/cookbook/screen_layout_rules_expand_3.xml[role=include]