|
Contents Overview Overview The layout system used by Jargon Software products is modeled on the "Gridbag" Layout Manager first used in the Java language environment. Java offers several different Layout Managers, which allow developers to design screen contents by using logical abstractions instead of hard-coded pixel coordinates. One of the advantages of this approach is that screens can automatically be resized without any additional development work if they are designed correctly to begin with. It also simplifies deployment into diverse environments that may have display devices with many different resolution levels. Of all of the Java Layout Managers, the oddly-named "GridBag" Layout Manager offers the most precise control in arranging components within a container, specifying the relative spacing between them, and controlling which components grow and by how much when their container is resized. Design of GridBag Layout Manager. The GridBag Layout Manager places all components into cells in an X/Y rectangular grid system. The X coordinate specifies the horizontal positioning within the grid, with X = 0 meaning the leftmost column, X = 1 being the next column to the right, and so on. Likewise, the Y coordinate specifies the vertical positioning within the grid, with Y = 0 being the top row, Y = 1 being the next row down, and so on. There are also width and height values which specify how many columns wide and how many rows high an individual component is. In Jargon Writer, these X/Y coordinates and width/height values are determined automatically, based on how components are positioned within the grid and on how many cells they occupy. The Manager automatically determines how many rows and columns are used by examing the constraints (parameters) of each component in a container. Any row that is completely unoccupied by any part of any component is ignored, as if it were not there, and likewise for empty columns. This means that leaving empty rows and columns between components will not affect the graphical representation of the layout in any way. A panel with one label in cell (0,0) and one textfield in the cell to its immediate right (1,0) will look exactly like a similar panel where the textfield is in a cell one grid position to the right (2,0) with one empty cell between it and the label. However, the latter panel is a better layout design because it makes it easier to add more components or to rearrange components in some future revision. Unlike in simpler layout systems, a GridBag component does not necessarily fill its entire cell, and cells in one row or column may be larger or smaller than those in another row or column. Any given cell will be at least as large as the component it contains (inset constraints can make it larger than its component), and all cells in a given row or column will be as large as the largest cell in that row or column. When one component is significantly wider or higher than other components, it is often desirable to change it to occupy more than one cell vertically or horizontally, so that two or more smaller components may fit alongside it or above/below it. In Jargon Writer, this is done by dragging one edge of the component to "stretch" it into two or more cells across or down in the grid space.
Constraints.
Container constraint.
Figure 1 below may help explain the purpose and function of the other constraints which follow.
Fill constraints.
Anchor constraints.
Pad constraints.
The current Swing version (1.0.2) adds one-half of the pad value to each side of the container, even though the official Sun documentation says that the total pixels added are twice the value you specify. For example, if you specify a Pad X value of 100 pixels, this will result in adding 50 pixels to the left side of the component and 50 pixels to the right, thus making the component wider by a total of 100 pixels. Pad Y values act similarly.
Inset constraints.
Insets may make a cell larger, if the existing component size plus the inset value are larger than the current cell size. However, if a component is in a cell considerably larger than the component (because some other cell in the same row or column is that large), then the inset serves only to position the component within the existing cell boundaries, in combination with the positioning caused by anchoring.
Weight X and Weight Y constraints.
Weights are decimal values between 0.0 (meaning no resizing) and 1.0. A nonzero value specifies the relative number of pixels by which a cell size changes when its frame grows or shrinks. For example, the cell of a component with a WeightX value of 0.3 will grow wider by three pixels for every one pixel that the cell of another component with a WeightX value of 0.1 will receive when the frame containing them grows wider.
Up to Top Return to Help Index |