Class UIGridBagLayout
public class UIGridBagLayout extends UILayoutManager
{
// Constructors
public UIGridBagLayout();
// Methods
public void addLayoutComponent(IUIContainer cont,
IUIComponent comp, Object constraints);
public int getAlignment();
public UIGridBagConstraints getConstraints(IUIComponent comp);
public Dimension getMinimumSize(IUIContainer parent);
public Dimension getPreferredSize(IUIContainer c,
Rectangle parentRect, boolean pref);
public Dimension getPreferredSize(IUIContainer parent);
public Dimension getPreferredSize(IUIContainer parent,
Rectangle rect);
public void layout(IUIContainer c, Rectangle bounds,
int alignment);
public void layout(IUIContainer parent, Rectangle bounds);
protected UIGridBagConstraints lookupConstraints(
IUIComponent comp);
public void setAlignment(int align);
public void setConstraints(IUIComponent comp,
UIGridBagConstraints cons);
public void setConstraints(IUIComponent comp,
GridBagConstraints cons);
}
This class implements a frame manager with a row by column format or grid for placing components. This class allows components of different sizes to be placed in a single container. The default alignment is centered.
Note A row will be as tall and as wide as the largest component. The class UIGridLayout is a much simpler version of the UIGridBagLayout. It does not allow variable row or column sizing. The following NAVDIR values are not supported in UIGridBagLayout.
- NAVDIR_UP
- NAVDIR_DOWN
- NAVDIR_LEFT
- NAVDIR_RIGHT
Also see com.ms.ui.UIGridLayout
UILayoutManager
|
+--UIGridBagLayout
public UIGridBagLayout();
Creates a new instance of a UIGridBagLayout. Use addLayoutComponent to add components to the UIGridBagLayout container.
See Also: addLayoutComponent, com.ms.ui.UIGridBagConstraints
public void addLayoutComponent(IUIContainer cont, IUIComponent comp, Object
constraints);
Adds the specified component to the layout, using the specified constraint object.
Return Value:
No return value.
Parameter | Description |
cont
| The container of the component.
|
comp
| The component to be added.
|
constraints
| Where or how the component is added to the layout.
|
Overrides:
addLayoutComponent(IUIContainer,IUIComponent,Object) in UILayoutManager.
Exceptions:
IllegalArgumentException
if the constraints passed in are not proper UIGridBagConstraints.
See Also: com.ms.ui.UIGridBagConstraints
public int getAlignment();
Retrieves the current layout alignment.
Return Value:
Returns an integer indicating the alignment of the container's components. For a list of possible values, see setAlignment.
See Also: setAlignment
public UIGridBagConstraints getConstraints(IUIComponent comp);
Retrieves a copy of the constraints for the specified component.
Return Value:
Returns the constraints for the specified component.
Parameter | Description |
comp
| The component to be queried.
|
public Dimension getMinimumSize(IUIContainer parent);
Determines the minimum dimensions (in pixels) needed to lay out the child components in the specified container.
Return Value:
Returns a Dimension object containing the minimum layout size.
Parameter | Description |
parent
| The container of the components.
|
Remarks:
This method is called by the container's getMinimumSize method.
Overrides:
getMinimumSize(IUIContainer) in UILayoutManager.
See Also: getPreferredSize
public Dimension getPreferredSize(IUIContainer c, Rectangle parentRect,
boolean pref);
Determines the preferred dimensions (in pixels) for laying out the components in the specified container.
Return Value:
Returns a Dimension object containing the preferred layout size.
Parameter | Description |
c
| The container of the components.
|
parentRect
| The bounding parent rectangle.
|
pref
| If set to true, getPreferredSize will be used; if set to false, getMinimumSize is used.
|
Remarks:
This method is called by the container's getPreferredSize method.
See Also: getMinimumSize, com.ms.ui.UIGridBagConstraints
public Dimension getPreferredSize(IUIContainer parent);
Determines the preferred dimensions (in pixels) for laying out the child components in the specified container.
Return Value:
Returns a Dimension object containing the preferred layout size.
Parameter | Description |
parent
| The container of the components.
|
Remarks:
This method is called by the container's getPreferredSize method.
Overrides:
getPreferredSize(IUIContainer) in UILayoutManager.
See Also: getMinimumSize
public Dimension getPreferredSize(IUIContainer parent, Rectangle rect);
Determines the preferred dimensions (in pixels) for laying out the child components in the specified container.
Return Value:
Returns a Dimension object containing the preferred layout size.
Parameter | Description |
parent
| The container of the components.
|
rect
| The bounding rectangle.
|
Remarks:
This method is called by the container's getPreferredSize method.
See Also: getMinimumSize
public void layout(IUIContainer c, Rectangle bounds, int alignment);
Lays out the components in the specified container. The grid of cells can be positioned within the container using alignment (see UIGridBagConstraints.anchor for values).
Return Value:
No return value.
Parameter | Description |
c
| The container being laid out.
|
bounds
| The bounding rectangle in which to lay out the components.
|
alignment
| Specifies how to anchor the grid of cells within the container.
|
Remarks:
This method is called by the container's layout method.
See Also: com.ms.ui.UIGridBagConstraings.anchor
public void layout(IUIContainer parent, Rectangle bounds);
Lays out the components in the specified container.
Return Value:
No return value.
Parameter | Description |
parent
| The container being laid out.
|
bounds
| The bounding rectangle in which to lay out the components.
|
Remarks:
This method is called by the container's layout method.
Overrides:
layout(IUIContainer,Rectangle) in UILayoutManager.
protected UIGridBagConstraints lookupConstraints(IUIComponent comp);
Retrieves the constraints for the specified component. The return value is not a copy, but is the actual constraints class used by the layout mechanism.
Return Value:
Returns the constraints for the specified component.
Parameter | Description |
comp
| The component to be queried.
|
public void setAlignment(int align);
Sets the layout alignment.
Return Value:
No return value.
Parameter | Description |
align
| The alignment for the container's components. See UIGridBagConstraints for possible anchor values.
|
See Also: getAlignment, com.ms.ui.UIGridBagConstraints
public void setConstraints(IUIComponent comp, UIGridBagConstraints cons);
Sets the constraints for the specified component.
Return Value:
No return value.
Parameter | Description |
comp
| The component to be modified.
|
cons
| The constraints to be applied.
|
See Also: com.ms.ui.UIGridBagConstraints
public void setConstraints(IUIComponent comp, GridBagConstraints cons);
Sets the constraints for the specified component.
Return Value:
No return value.
Parameter | Description |
comp
| The component to be modified.
|
cons
| The constraints to be applied.
|
See Also: com.ms.ui.UIGridBagConstraints