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

Class UIItem

Constructors , Methods , Fields

public class UIItem extends UIStatic
{
  // Fields
  public static final int ONLEFT;
  public static final int ABOVE;
  public static final int FIRSTLINE;

  // Constructors
  public UIItem();
  public UIItem(Image image, String text);
  public UIItem(Image image, String text, int justify);
  public UIItem(Image image, String text, int justify, int imagePos);

  // Methods
  public int getGap();
  public Image getImage();
  public int getImagePos();
  public String getName();
  public int getRoleCode();

  public void setGap(int gap);
  public void setImage(Image image);
  public void setImagePos(int imagePos);
  public void setName(String text);

  public void setFocus(boolean on);
  public void setHot(boolean on);
  public void setSelected(boolean on);

  public Dimension minimumSize();
  public boolean imageUpdate(Image image, int flags, int x, int y, 
                             int width, int height);
  public void initGraphics();
  public void paint(Graphics g, Rectangle rect);

}

A class that manages an item static control object; used to display both graphical and text information.


Constructors


UIItem

public UIItem();

Creates a static item control with no image or text.


UIItem

public UIItem(Image image, String text);

Creates a static item control containing the specified image and text; sets the justification to centered and its image position to ONLEFT.

ParameterDescription
image The image to be displayed.
text The text to be displayed.


UIItem

public UIItem(Image image, String text, int justify);

Creates a static item control containing the specified image and text with the specified justification; sets its image position to ONLEFT.

ParameterDescription
image The image to be displayed.
text The text to be displayed.
justify The justification used when arranging content within control.


UIItem

public UIItem(Image image, String text, int justify, int imagePos);

Creates a static item control containing the specified image and text with the specified justification and with a specified image position.

ParameterDescription
image The image to be displayed.
text The text to be displayed.
justify The justification used when arranging content within the control.
imagepos The position of image relative to text.


Methods


getGap

public int getGap();

Retrieves the size of the gap between the image and text in the control.

Return Value:

Returns the number of pixels in the gap.

Remarks:

If the image is positioned above the text, this gap is the vertical space between the image and text. Otherwise, the gap is the horizontal space between the two.


getImage

public Image getImage();

Retrieves the image that is displayed by the control.

Return Value:

Returns an Image object containing the control's image.


getImagePos

public int getImagePos();

Retrieves the image position within the control relative to the text.

Return Value:

Returns the image position, which can be ONLEFT, ABOVE, or FIRSTLINE.


getName

public String getName();

Retrieves the text that is displayed by the control.

Return Value:

Returns a String object containing the item's text.


getRoleCode

public int getRoleCode();

Retrieves the role of the control.

Return Value:

Returns the ROLE_SYSTEM code that best describes the role of the control.

Remarks:

This method returns the ROLE_SYSTEM_GRAPHIC code.


imageUpdate

public boolean imageUpdate(Image image, int flags, int x, int y, 
                           int width, int height);

Updates the image displayed by the control.

Return Value:

Returns false if the image passed is not the image displayed by the control.

ParameterDescription
image The image displayed by the control.
flags Flags that specify information about the image update. You can pass any bitwise combination of the fields defined in the ImageObserver interface.
x The x coordinate for the clipping rectangle used by this graphics context.
y The y coordinate for the clipping rectange used by this graphics context.
width The width of the clipping rectangle.
height The height of the clipping rectangle.


initGraphics

public void initGraphics();

Initializes the graphics when the graphics context is initially made available.

Return Value:

No return value.

Remarks:

This method is used instead of the constructor to do an initialization that requires the graphics context. In this case, it computes the size of the item.


minimumSize

public Dimension minimumSize();

Determines the minimum size of the control. The minimum size specifies the smallest dimensions (in pixels) that will allow the control's content to be displayed.

Return Value:

Returns a Dimension object containing the minimum size.


paint

public void paint(Graphics g, Rectangle rect);

Repaints the image control within the specified rectangle.

Return Value:

No return value.

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

Overrides:

Overrides paint in class UIStatic.


setFocus

public void setFocus(boolean on);

Sets the focus state of this object.

Return Value:

No return value.

ParameterDescription
on Set to true to enable the state; set to false to disable this state.

Remarks:

This method forces a repaint if the control contains text.

Overrides:

Overrides setFocus in class UICanvas.


setGap

public void setGap(int gap);

Sets the size of the gap between the image and text in the control.

Return Value:

No return value.

ParameterDescription
gap The size of gap between image and text (in pixels).

Remarks:

If the image is positioned above the text, this gap is the vertical space between the image and text. Otherwise, the gap is the horizontal space between the two.


setHot

public void setHot(boolean on);

Sets the hot-track state of this object.

Return Value:

No return value.

ParameterDescription
on Set to true to enable the state; set to false to disable this state.

Remarks:

This method forces a repaint if the control contains text.

Overrides:

Overrides setHot in class UICanvas.


setImage

public void setImage(Image image);

Sets the image that is displayed by the control.

Return Value:

No return value.

ParameterDescription
image The image to be displayed.


setImagePos

public void setImagePos(int imagePos);

Sets the image position within the control relative to the text.

Return Value:

No return value.

ParameterDescription
imagePos The image position relative to the text. You can specify ONLEFT, ABOVE, or FIRSTLINE.

Remarks:

An IllegalArgumentException is thrown if an invalid position is specified.


setName

public void setName(String text);

Sets the text that is displayed by the control.

Return Value:

No return value.

ParameterDescription
text The text that is displayed by the control.


setSelected

public void setSelected(boolean on);

Sets the selected state of this object.

Return Value:

No return value.

ParameterDescription
on Set to true to enable the state; set to false to disable this state.

Remarks:

This method forces a repaint if the control contains text.

Overrides:

Overrides setSelected in class UICanvas.


Fields

ONLEFT
Position the image to the left of the text.
ABOVE
Position the image above the text.
FIRSTLINE
Position the image in the first line of text.


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