About PaneLayout

PaneLayout allows you to specify the size of a component in relation to its sibling components. PaneLayout applied to a panel or frame lets you control the percentage of the container the components will have relative to each other, but does not create moveable splitter bars between the panes.

Split Panel image

In a PaneLayout, the placement and size of each component is specified relative to the components that have already been added to the container. Each component specifies a PaneConstraints object that tells the layout manager from which component to take space, and how much of its existing space to take. Each component's PaneConstraints object is applied to the container as it existed at the time the component was added to the container. The order in which you add the components to the container is very important.

PaneConstraint Variables

The constraint for a PaneConstraints component that is being added to a container consists of four variables:

String name

The name for this component (must be unique for all components in the container - as in CardLayout).
 
String splitComponentName

The name of the component from which space will be taken to make room for this component.
 
String position

The edge of the splitComponentName to which this component will be anchored.

Valid values are:

Select this To do this

PaneConstraints.TOP

This component will be above splitComponentName.

PaneConstraints.BOTTOM

This component will be below splitComponentName.

PaneConstraints.RIGHT

This component will be to the right of splitComponentName .

PaneConstraints.LEFT

This component will be to the left of splitComponentName .

PaneConstraints.ROOT

This component is the first component added.

 
float proportion

The proportion of splitComponentName that will be allocated to this component. A number between 0 and 1.

How Components are Added to PaneLayout

Creating a PaneLayout Container in the Java Visual Editor

  1. Add a container to your UI in the Java Visual Editor. This can be any kind of a frame or panel.

    empty frame

  2. Change the container's layout property to PaneLayout . This allows you to access the PaneLayout properties in the Inspector.
  3. From the Component Palette, select the first component and drop it into the PaneLayout container. This component will completely fill the container until you add another component.

    PaneLayout Container illustration image

  4. Select the second component and drag it to the desired size in the desired position.

    PaneLayout Container illustration image

    Important: If the first component you added to a PaneLayout container was itself a container, the Java Visual Editor assumes you are trying to add the second component to the outer container instead of to the PaneLayout container. Use the component tree to specify to the containers that you want the component to be placed in.

  5. To add a third component to the PaneLayout, draw it similarly to define its position relative to the other components.

    For example, to split the right half of the container, begin drawing the third component starting from the middle of the right edge of the panel to the bottom right corner of the first component.

    PaneLayout Constraints illustration image

  6. Use the same method to add subsequent components.