Panels

Although Pivot's automatic layout management features are convenient, sometimes it is preferable to perform layout manually (for example, when aligning components to an existing graphical asset being used as a background image). The Panel container can be used for this purpose. Panel performs no layout or preferred size calculations itself, giving the application complete control over components' size and position.

The following example demonstrates use of the Panel container. It defines a stack pane that contains an ImageView and a Panel. The image view contains a drawing that defines an absolutely positioned rectangle. The buttons in the Panel, which sits on top of the ImageView, are absolutely positioned such that they appear within the bounds of the rectangle:

The BXML source code for this example is as follows:

            
            <Window title="Panels" maximized="true"
                xmlns:bxml="http://pivot.apache.org/bxml"
                xmlns:media="org.apache.pivot.wtk.media"
                xmlns="org.apache.pivot.wtk">
                <Border>
                    <Panel>
                        <PushButton buttonData="Button 1"
                            x="20" y="20" width="120" height="24"/>
                        <PushButton buttonData="Button 2"
                            x="40" y="50" width="120" height="24"/>
                        <PushButton buttonData="Button 3"
                            x="60" y="80" width="120" height="24"/>
                    </Panel>
                </Border>
            </Window>
            
        

Since this example contains no logic, there is no associated Java source.

Next: Navigation Containers