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

Class UIPushButton

Constructors , Methods , Fields

public class UIPushButton extends UIButton
{
  // Fields
  public static final int RAISED;

  // Constructors
  public UIPushButton();
  public UIPushButton(String text);
  public UIPushButton(String text, int style);
  public UIPushButton(Component comp);
  public UIPushButton(Component comp, int style);

  // Methods
  public void setChecked(boolean on);  
  public void setFocus(boolean on);
  public void setHot(boolean on);
  public void setPressed(boolean on);
  public void setStyle(int style);

  public Dimension minimumSize();
  public Dimension preferredSize();

  public int getRoleCode();

  public void layout();
  public void paint(Graphics g);
  
}

A class that implements a push button control. For more information about using buttons, see the UIButton overview.


Constructors


UIPushButton

public UIPushButton();

Creates a push button control with no content.

Remarks:

By default, the button's style is RAISED.


UIPushButton

public UIPushButton(String text);

Creates a push button control using the specified text for content.

ParameterDescription
text The text to be displayed within the button.

Remarks:

By default, the button has a flat style, and the text is centered and hot-tracked. To create a button whose text is not hot-tracked, pass a UIText object instead of a String, as shown in the following example.

UIPushButton p = 
   new UIPushButton(new UIText("Text not hot-tracked"));

For more information about hot-tracking, see the UIButton overview.


UIPushButton

public UIPushButton(String text, int style);

Creates a push button control using the specified text for content and the specified style.

ParameterDescription
text The text to be displayed within the button.
style The style of the button. You can pass any bitwise combination of UIPushButton.RAISED, UIButton.TOGGLE, and UIButton.TRITOGGLE. (Note that combining TOGGLE and TRITOGGLE results in TRITOGGLE.) To specify a flat style, pass 0 for this parameter.

Remarks:

By default, the text is centered and hot-tracked. If any undefined style bits are specified, an IllegalArgumentException is thrown.

To create a button whose text is not hot-tracked, pass a UIText object instead of a String, as shown in the following example.

UIPushButton p = 
   new UIPushButton(new UIText("Text not hot-tracked"), 0);

For more information about hot-tracking, see the UIButton overview.


UIPushButton

public UIPushButton(Component comp);

Creates a push button control using the specified component for content.

ParameterDescription
comp The component to be displayed within the button.

Remarks:

By default, the component is centered and the button's style is RAISED. Typically, you'll pass a UIText, UIGraphic, or UIItem object for the component. For examples of how to construct buttons, see the UIButton overview.


UIPushButton

public UIPushButton(Component comp, int style);

Creates a push button control using the specified component for content and the specified style.

ParameterDescription
comp The component to be displayed within the button.
style The style of the button. You can pass any bitwise combination of UIPushButton.RAISED, UIButton.TOGGLE, and UIButton.TRITOGGLE. (Note that combining TOGGLE and TRITOGGLE results in TRITOGGLE.) To specify a flat style, pass 0 for this parameter.

Remarks:

By default, the component is centered. If any undefined style bits are specified, an IllegalArgumentException is thrown. Typically, you'll pass a UIText, UIGraphic, or UIItem object for the component. For examples of how to construct buttons, see the UIButton overview.


Methods


getRoleCode

public int getRoleCode();

Retrieves the role of the push button.

Return Value:

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

Remarks:

This method returns the ROLE_SYSTEM_PUSHBUTTON code.


layout

public void layout();

Lays out the push button control.

Return Value:

No return value.


minimumSize

public Dimension minimumSize();

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

Return Value:

Returns a Dimension object containing the minimum size.


paint

public void paint(Graphics g);

Draws the push button control.

Return Value:

No return value.

ParameterDescription
g The graphics context.

Remarks:

This method checks all states and styles of the button and draws the corresponding button image. The button control's content is also redrawn.


preferredSize

public Dimension preferredSize();

Determines the preferred size of the button control. The preferred size specifies the dimensions (in pixels) you want for the button.

Return Value:

Returns a Dimension object containing the preferred size.

Remarks:

By default, this method returns the minimum size as determined by minimumSize.


setChecked

public void setChecked(boolean on);

Sets or clears the checked state of the button.

Return Value:

No return value.

ParameterDescription
on If true, the checked state is set; otherwise, it is cleared.

Remarks:

This method automatically lays out the content and repaints the button to display the new state. For more information about button states, see the UIButton overview.


setFocus

public void setFocus(boolean on);

Sets or clears the focus state of the button.

Return Value:

No return value.

ParameterDescription
on If true, the focus state is set; otherwise, it is cleared.

Remarks:

If necessary, this method automatically lays out the content and repaints the button to display the new state. For more information about button states, see the UIButton overview.


setHot

public void setHot(boolean on);

Sets or clears the hot-tracked state of the button.

Return Value:

No return value.

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

Remarks:

If necessary, this method automatically lays out the content and repaints the button to display the new state. For more information about button states, see the UIButton overview.


setPressed

public void setPressed(boolean on);

Sets or clears the pressed state of the button.

Return Value:

No return value.

ParameterDescription
on If true, the pressed state is set; otherwise, it is cleared.

Remarks:

This method automatically lays out the content and repaints the button to display the new state. For more information about button states, see the UIButton overview.


setStyle

public void setStyle(int style);

Sets the current style for the button.

Return Value:

No return value.

ParameterDescription
style The style of the button. You can pass any bitwise combination of UIPushButton.RAISED, UIButton.TOGGLE, and UIButton.TRITOGGLE. (Note that combining TOGGLE and TRITOGGLE results in TRITOGGLE.) To specify a flat style, pass 0 for this parameter.

Remarks:

If any undefined style bits are specified, an IllegalArgumentException is thrown.


Fields

RAISED
Specifies that the push button is raised.


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