Class AwtUIButton
public abstract class AwtUIButton extends AwtUIControl
{
// Constructors
public AwtUIButton();
// Methods
public int getStyle();
public boolean keyDown(Event e, int key);
public boolean keyUp(Event e, int key);
public boolean mouseUp(Event e, int x, int y);
public void setLabel(String name);
public void setStyle(int style);
}
This class implements the functionality of a UIButton object in an AWT-based control. The following classes extend AwtUIButton and allow you to create AWT-based buttons.
While an AwtUIButton control is fully compatible with AWT, a UIButton control is optimized for performance and size.
Panel
|
+--AwtUIHost
|
+--AwtUIControl
|
+--AwtUIButton
public AwtUIButton();
Creates an AWT-based button control.
public int getStyle();
Retrieves the button's current style settings.
Return Value:
Returns an integer containing the current style settings. For a list of possible styles, see setStyle.
public boolean keyDown(Event e, int key);
Determines whether the SPACEBAR or the ENTER key is being pressed, and if so, sets the pressed state.
Return Value:
Returns true if the event was handled; otherwise, returns false.
Parameter | Description |
e
| The event posted to the button control.
|
key
| The key that has been pressed.
|
Remarks:
This method is called when the button has focus and a key is pressed. If the key being pressed is the SPACEBAR or the ENTER key, the button's pressed state is set. If the ESC key is being pressed, the button's pressed state is cleared.
For more information about states, see the UIStateContainer overview.
See Also: keyUp
public boolean keyUp(Event e, int key);
Determines whether the SPACEBAR or the ENTER key is being released, and if so, generates an action event.
Return Value:
Returns true if the event was handled; otherwise, returns false.
Parameter | Description |
e
| The event posted to the button control.
|
key
| The key that has been released.
|
Remarks:
This method is called when the button has focus and a key is released. If the key being released is the SPACEBAR or the ENTER key, an action event is generated. The keyUp method also clears the button's pressed state, which was previously set by keyDown.
For more information about states, see the UIStateContainer overview.
See Also: keyDown
public boolean mouseUp(Event e, int x, int y);
Determines whether the button control's pressed state is set, and if so, generates an action event.
Return Value:
Returns true if the event was handled; otherwise, returns false.
Parameter | Description |
e
| The event posted to the button control.
|
x
| The x coordinate of the event.
|
y
| The y coordinate of the event.
|
Remarks:
The pressed state is set when the mouse button is pressed over the control. When the mouse button is released, mouseUp then clears the pressed state and generates an action event.
public void setLabel(String name);
Sets the content of the button to the specified name.
Return Value:
No return value.
Parameter | Description |
name
| The string to be displayed by the button.
|
public void setStyle(int style);
Sets the button's current style.
Return Value:
No return value.
Exceptions:
IllegalArgumentException
if an undefined style was specified.
See Also: getStyle