Skip navigation links

Codename One API

Package com.codename1.ui.layouts

Layout managers allow a Container to arrange its components by a set of rules that adapt to specific densities (ppi - pixels per inch).

See: Description

Package com.codename1.ui.layouts Description

Layout managers allow a Container to arrange its components by a set of rules that adapt to specific densities (ppi - pixels per inch). A layout manager is an arranging algorithm encapsulated by an abstract class implementation that places components absolutely based on the "hints" received.

Layout Managers that ship with Codename One

FlowLayout is default layout manager, simple, flexible and with a few caveats.

Simple FlowLayout

BorderLayout is ubiquitous thru Codename One code.

Border Layout

BorderLayout can also behave differently based on the center behavior flag

Border Layout Center

BoxLayout Y axis is a the work-horse of component lists

Box Layout Y

BoxLayout X axis is a simpler replacement to flow layout and has grow/no grow variants.

Box Layout X
Box Layout X No Grow

GridLayout arranges elements in a grid where all elements have an equal size. It can auto adapt the column count.

Grid Layout 2x2 Grid Layout autofit landscape

TableLayout is similar in many regards to HTML tables. Notice that its in the com.codename1.ui.table package and not in this package.

TableLayout that grows the last column TableLayout with complex constraints

LayeredLayout is unique in the sense that it is meant to costruct layers and not the UI positions. It only lays out on the Z axis.

The X on this button was placed there using the layered layout code below

GridBagLayout was added to Codename One to ease the porting of Swing/AWT applications.

Sample gridbag layout usage

MigLayout is a popular 3rd party layout manager its Codename One port is experimental.

MiG Layout
Skip navigation links
Developed by Codename One