Package com.ms.awt |
![]() Previous |
![]() Microsoft Packages |
![]() Index |
![]() Next |
public class DialogLayout implements LayoutManager { // Constructors public DialogLayout(Container parent, int width, int height); public DialogLayout(Container parent, Dimension d); // Methods public void setShape(Component comp, int x, int y, int width, int height) public void setShape(Component comp, Rectangle rect) public Rectangle getShape(Component comp) public Dimension getDialogSize() public void addLayoutComponent(String name, Component comp) { } public void removeLayoutComponent(Component comp) { } public Dimension preferredLayoutSize(Container parent) public Dimension minimumLayoutSize(Container parent) public void layoutContainer(Container parent) }
DialogLayout is a simple layout manager which works with what the Win32 API calls "dialog logical units" (DLUs). DLUs are resolution independent coordinates which work well for laying out controls on a dialog box. The mapping from DLUs to pixels is based on the font in use in the dialog box. An x-coordinate DLU is described as 1/4 (.25) of the of the average character width of the font used in the dialog. A y-coordinate DLU is described as 1/8 (.125) of the character height used in the dialog.
Note The average character width is not the average of all characters — rather it is the average of all alpha characters both uppercase and lowercase. That is, it is the extent of the string "a...zA...Z" divided by 52.
This class allows you to associate a rectangle (x, y, width, height) with a component in a container. If called upon to layout the container, this layout manager will layout based on the translation of dialog units to pixels.
public DialogLayout(Container parent, int width, int height)Sets the dimensions of the parent container, using the given width and height and the average character width and height of the parent.
Parameter Description parent The container. width Specifies the width, in DLUs, of the dialog box. height Specifies the height, in DLUs, of the dialog box. See Also: Container
public DialogLayout(Container parent, Dimension d)Sets the dimensions of the parent container, using the width and height specified by the parameter d and the average character width and height of the parent.
Parameter Description parent The container. d Specifies the width and height, in DLUs, of the dialog box. See Also: Container
public void setShape(Component comp, int x, int y, int width, int height)Sets the position and shape of the given component.
Return Value:
No return value.
Parameter Description comp The component. x and y The position, in DLUs, of the upper left corner of the component relative to the upper left corner of the parent container. width and height The width and height of the component in DLUs. See Also: Component
public void setShape(Component comp, Rectangle rect)Sets the position and shape of the given component using values from the given rectangle.
Return Value:
No return value.
Parameter Description comp The component. rect The x and y fields specify the position, in DLUs, of the upper left corner of the component relative to the upper left corner of the parent container. The width and height fields specify the width and height, in DLUs, of the component.
public Rectangle getShape(Component comp)Retrieves a rectangle that defines the position and shape of the given component.
Return Value:
Returns a rectangle: x and y fields specify the position of the component (relative to the upper left corner of the container), and width and height specify the component width and height. All values are in DLUs.
Parameter Description comp The component.
public Dimension getDialogSize()Retrieves the dimensions of the parent container associated with this layout.
Return Value:
Returns a dimension with the width and height fields specifying width and height in pixels.
public void addLayoutComponent(String name, Component comp)This method is not used by the dialog layout manager.
Return Value:
No return value.
public void removeLayoutComponent(Component comp)This method is not used by the dialog layout manager.
Return Value:
No return value.
public Dimension preferredLayoutSize(Container parent)Determines the preferred size of the parent container using this dialog layout.
Most applications do not call this method directly. This method is called when a container calls its preferredSize method.
Return Value:
Returns the preferred dimensions to lay out the subcomponents of the specified container.
Parameter Description parent The container in which to do the layout.
public Dimension minimumLayoutSize(Container parent)Determines the minimum size of the parent container using this dialog layout.
This method is called when a container calls its layout method . Most applications do not call this method directly.
Return Value:
Returns the minimum dimensions needed to lay out the subcomponents of the specified container.
Parameter Description parent The container in which to do the layout.
public void layoutContainer(Container parent)Lays out the container argument using this dialog layout.
Each component in the parent container is reshaped based on its size in DLUs and the average character width and height of the current font for the parent.
Most applications do not call this method directly. This method is called when a container calls its layout method.
Return Value:
No return value.
Parameter Description parent The container in which to do the layout.