XYLayout
XYLayout is a Borland JBuilder custom layout manager. XYLayout puts components in a container at specific x,y coordinates relative to the upper left corner of the container. Regardless of the type of display, the container will always retain the relative x,y positions of components. However, when you resize a container with an XYLayout, the components do not reposition or resize.
Example
You'll discover that XYLayout is very convenient to use for protoyping your design work. When you design more complicated user interfaces with multiple, nested panels, XYLayout can be used for the initial layout of the panels and components, after which you can choose from one of the standard layouts for the final design.
Note: To ensure your layout will be nicely laid out on other displays, don't leave any containers in XYLayout in your final design.
You can use the visual design tools to specify the container's size and its components' x,y coordinates.
- To specify the size of the XYLayout container, select the XYLayout object in the Component Tree and enter the pixel dimension for the height and width properties in the Inspector. This sets the size of the XYLayout container.
- To change the x,y values for a component inside an XYLayout container, do one of the following:
- In the UI Designer, drag the component to a new size. JBuilder automatically updates the constraint values in the Inspector.
- Select the component in the Tree, then click the constraints property edit field and enter coordinates for that component.
Aligning components in XYLayout
You can adjust the alignment of a group of selected components in a container that uses XYLayout. Alignment does not work for other layouts. See Using layout managers.
With alignment operations, you can make a set of components the same width, height, left alignment, and so on, so that they look cleanly organized.
To align components,
- Select the components you wish to align. The order of selection affects the alignment, as described in the table below.
- Right click in the UI Designer and select the alignment operation you wish to perform.
Alignment options for XYLayout
The following table explains the alignment options available from the pop-up menu:
|
| Select this | To do this |
|
| Move to first | Move the select component to the top of the Z-order. |
| Move to last | Move the select component to the bottom of the Z-order. |
| Align Left | Line up the left edges of the components with the left edge of the first selected component. |
| Align Center | Horizontally line up the centers of the components with the center of the first selected component. |
| Align Right | Line up the right edges of the components with the right edge of the first selected component. |
| Align Top | Line up the top edges of the components with the top edge of the first selected component. |
| Align Middle | Vertically line up the centers of the components with the middle of the first selected component. |
| Align Bottom | Line up the bottom edges of the components with the bottom edge of the first selected component. |
| Even Space Horizontal | Evenly space the components horizontally between the first and last selected components. |
| Even Space Vertical | Evenly space the components vertically between the first and last selected components. |
| Same Size Horizontal | Make the components all the same width as the first selected component. |
| Same Size Vertical | Make the components all the same height as the first selected component. |
|
Null
Null layout means no layout manager is assigned to the container. Null layout (from Swing) is very similar to the JBCL XYLayout, in that you can put components in a container at specific x,y coordinates relative to the upper left corner of the container. You must specify each component's x,y coordinates in its constraints property.