tell me more icon BorderLayout and Constraints

A Java UI container uses a special object called a layout manager to control how components in the container are located and sized each time the container is displayed. A layout manager automatically arranges the components in the container according to a particular set of rules specific to that layout manager. Layout managers allow you to specify rules and constraints for the layout of your UI in a way that will be portable across platforms.

Initially the dataPanel container in the client form does not include a layout manager, as shown by <null> in the Structure window of Form.java with dataPanel expanded:

Structure window, panelOrdersViewHelper

To use a layout manager, expand the Visual section in the Property Inspector for dataPanel, and change the layout attribute to BorderLayout:

Property Inspector, dataPanel, layout

The BorderLayout layout manager arranges a container's components in one of five areas within a BorderLayout, based on the constraints property of the component. You can set the constraints property for the component in the Property Inspector to one of the five following values:

  • North or South: Components in North and South are given their preferred height and are stretched across the full width of the container.
  • East or West: The components in East and West are given their preferred width and are stretched vertically to fill the space between the north and south areas.
  • Center: A component in the Center expands to fill all remaining space.

Constraints property values for BorderLayout

For example, the constraints property for dataPanel is Center, as shown in the Property Inspector:

Property Inspector, constraints

You can also use the Constraints property visual editor to change a component's constraints property value by selecting an appropriate box:

Constraints property editor, dataPanel

After setting BorderLayout as the layout manager for the dataPanel container, you are ready to change the constraints property value for the container's component panelOrdersView1Helper1 (which is the edit form panel you added previously).

The master edit form is not going to grow in size because it has a fixed number of columns (label and text field) and rows (number of attributes). In the next step you will select panelOrdersView1Helper1 in the Structure window, and then use the Constraints property visual editor to change the constraints property value of panelOrdersView1Helper1 to North. This enables the edit form to always be stretched across the full width of the container.

Structure window Constraints property editor, edit form panel

Note: The Constraints property visual editor is located next to the Property Inspector by default. If the Constraints property visual editor is not already open, choose View then choose Java then choose Constraints .

Copyright © 1997, 2009, Oracle. All rights reserved.

false ,,,,,,,,,,,,,,,