Package com.ms.ui Previous
Previous
Contents
Contents
Index
Index
Next
Next

Class UIStatic

Constructors , Methods , Fields

public abstract class UIStatic extends UICanvas
{
  // Fields
  public static final int LEFT;
  public static final int RIGHT;
  public static final int TOP;
  public static final int BOTTOM;

  public static final int HCENTER;
  public static final int VCENTER;
  public static final int CENTERED;

  public static final int TOPLEFT;
  public static final int TOPRIGHT;
  public static final int BOTTOMLEFT;
  public static final int BOTTOMRIGHT;

  public static final int NOEDGE;
  public static final int HOTTRACK;

  // Constructors
  public UIStatic();
  public UIStatic(int style);

  // Methods
  public Dimension calcString(String text);  
  public Dimension calcString(Graphics g, String text);
  public void drawString(Graphics g, String text, Rectangle rect);

  public Dimension getContent();
  public Rectangle getContentBounds();

  public void setContent(int width, int height);
  public void setContent(Dimension content);
  public void setFlags(int style);
  public void setHot(boolean on);

  public Dimension minimumSize();
  public Dimension preferredSize();
  public void paint(Graphics g);
  public void paint(Graphics g, Rectangle rect);

}

An abstract class that manages a static control object. Controls of this type display information, and are often used as building blocks for other controls such as buttons, list boxes, and menus.


Constructors


UIStatic

public UIStatic();

Creates a static control with a style of CENTERED.


UIStatic

public UIStatic(int style);

Creates a static control with the specified style.

ParameterDescription
style The style of the control. Specify one of the UIStatic fields.


Methods


calcString

public Dimension calcString(String text); 

Calculates the dimensions of the bounding rectangle for the given string, based on the font metrics of the static control's graphics context.

Return Value:

Returns the dimensions of the text string.

ParameterDescription
text The text string.


calcString

public Dimension calcString(Graphics g, String text); 

Calculates the dimensions of the rectangle for the given string, based on the font metrics of the specified graphics context.

Return Value:

Returns the dimensions of the text string.

ParameterDescription
g The graphics context. If null, this method assumes the graphics context of the static control.
text The text string.


drawString

public void drawString(Graphics g, String text, Rectangle rect);

Draws the specified text in a rectangle using the specified graphics context.

Return Value:

No return value.

ParameterDescription
g The graphics context to paint the text in.
text The text to be painted.
rect The rectangle to paint the text in.


getContent

public Dimension getContent();

Retrieves the current dimensions of this control's contents.

Return Value:

Returns null if no content dimensions have been provided; otherwise, returns the dimensions of the content.


getContentBounds

public Rectangle getContentBounds();

Retrieves the dimensions of the contents to paint.

Return Value:

Returns a Rectangle that defines the size of the content area.


minimumSize

public Dimension minimumSize();

Retrieves the minimum size of the static control.

Return Value:

Returns the minimum size.


paint

public void paint(Graphics g);

Draws the static control.

Return Value:

No return value.

ParameterDescription
g The graphics context.


paint

public void paint(Graphics g, Rectangle rect);

Draws the static control within the specified rectangle.

Return Value:

No return value.

ParameterDescription
g The graphics context.
rect The rectangle in which to paint the control.

Remarks:

This method is currently not implemented here, however it is used in UIText.


preferredSize

public Dimension preferredSize();

Determines the preferred size of the static control.

Return Value:

Returns the preferred size.

Remarks:

The preferredSize is the width and height specified by the most recent call to the reshape or resize method.


setContent

public void setContent(int width, int height);

Sets the current dimensions of the control's contents, based on the specified values.

Return Value:

No return value.

ParameterDescription
width The width of the control's contents.
height The height of the control's contents.


setContent

public void setContent(Dimension content);

Sets the current dimensions of the control's contents, based on the specified Dimension object.

Return Value:

No return value.

ParameterDescription
content A Dimension object containing the dimensions for the control.


setFlags

public void setFlags(int style);

Sets the style of the static control.

Return Value:

No return value.

ParameterDescription
style The style of the control. Specify one of the UIStatic fields.

Remarks:

One vertical justification style and one horizontal justification style can be specified. If no vertical justification is specified, VCENTER is used by default. If no horizontal justification is specified, HCENTER is used by default. If more than one vertical justification or more than one horizontal justification is specifed, an IllegalArgumentException is thrown. The same exception is also thrown if an invalid bit is set.


setHot

public void setHot(boolean on);

Sets the hot-tracked state of the static control.

Return Value:

No return value.

ParameterDescription
on If true, the hot-tracked state is set; otherwise, it is cleared.

Remarks:

When the user moves the mouse over the control, hot-tracking indicates that the control will receive focus if selected.


Fields

LEFT
Specifies that the content is left-aligned.
RIGHT
Specifies that the content is right-aligned.
TOP
Specifies that the content is vertically aligned to the top.
BOTTOM
Specifies that the content is vertically aligned to the bottom.
HCENTER
Specifies that the content is centered horizontally.
VCENTER
Specifies that the content is centered vertically.
CENTERED
Specifies that the content is both horizontally and vertically centered.
TOPLEFT
Specifies that the content is horizontally left-aligned and vertically top-aligned.
TOPRIGHT
Specifies that the content is horizontally right-aligned and vertically top-aligned.
BOTTOMLEFT
Specifies that the content is horizontally left-aligned and vertically bottom-aligned.
BOTTOMRIGHT
Specifies that the content is horizontally right-aligned and vertically bottom-aligned.
NOEDGE
Specifies that the control has no defining edge.
HOTTRACK
Specifies that the control is hot-tracked.


Top© 1997 Microsoft Corporation. All rights reserved. Legal Notices.