|
Java DTV API 1.3 18-Nov-2009 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.sun.dtv.lwuit.Component
com.sun.dtv.lwuit.Label
com.sun.dtv.lwuit.Button
public class Button
Button is the base class for several UI widgets allowing clickability. It has 3 states: rollover, pressed and the default state it can also have ActionListeners that react when the Button is clicked.
Field Summary | |
---|---|
static int |
STATE_DEFAULT
Indicates the default state of a button which is neither pressed nor focused. |
static int |
STATE_PRESSED
Indicates the pressed state of a button. |
static int |
STATE_ROLLOVER
Indicates the rollover state of a button which is equivalent to focused for most uses. |
Fields inherited from class com.sun.dtv.lwuit.Component |
---|
BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, LEFT, RIGHT, TOP |
Fields inherited from interface com.sun.dtv.ui.ViewOnlyComponent |
---|
HORIZONTAL_ALIGN_CENTER, HORIZONTAL_ALIGN_JUSTIFIED, HORIZONTAL_ALIGN_LEFT, HORIZONTAL_ALIGN_RIGHT, SCALE_ASPECT_PROOF, SCALE_NO, SCALE_NO_ASPECT_PROOF, STATE_DISABLED, STATE_ENABLED, VERTICAL_ALIGN_BOTTOM, VERTICAL_ALIGN_CENTER, VERTICAL_ALIGN_JUSTIFIED, VERTICAL_ALIGN_TOP |
Fields inherited from interface com.sun.dtv.ui.Animated |
---|
ALTERNATING, LOOP, REPEATING |
Constructor Summary | |
---|---|
Button()
Constructs a button with an empty string for its text. |
|
Button(Command cmd)
Allows binding a command to a button for ease of use. |
|
Button(Image icon)
Constructs a button with the specified image. |
|
Button(String text)
Constructs a button with the specified text. |
|
Button(String text,
Image icon)
Constructor a button with text and image. |
Method Summary | |
---|---|
void |
addActionListener(ActionListener l)
Adds a listener to the button which will cause an event to dispatch on click. |
Image |
getPressedIcon()
Indicates the icon that is displayed on the button when the button is in pressed state. |
Image |
getRolloverIcon()
Indicates the icon that is displayed on the button when the button is in rolled over state. |
int |
getState()
Returns the button state. |
void |
keyPressed(int keyCode)
If this Component is focused, the key pressed event will call this method. |
void |
keyReleased(int keyCode)
If this Component is focused, the key released event will call this method. |
void |
paint(Graphics g)
This method paints the Component on the screen, it should be overriden by subclasses to perform custom drawing or invoke the UI API's to let the PLAF perform the rendering. |
void |
pointerPressed(int x,
int y)
If this Component is focused, the pointer pressed event will call this method. |
void |
pointerReleased(int x,
int y)
If this Component is focused, the pointer released event will call this method. |
void |
removeActionListener(ActionListener l)
Removes the given action listener from the button. |
void |
setPressedIcon(Image pressedIcon)
Indicates the icon that is displayed on the button when the button is in pressed state. |
void |
setRolloverIcon(Image rolloverIcon)
Indicates the icon that is displayed on the button when the button is in rolled over state. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public static final int STATE_ROLLOVER
public static final int STATE_PRESSED
public static final int STATE_DEFAULT
Constructor Detail |
---|
public Button()
public Button(String text)
text
- label appearing on the buttonpublic Button(Command cmd)
cmd
- command whose text would be used for the button and would
receive action events from the buttonpublic Button(Image icon)
icon
- appearing on the buttonpublic Button(String text, Image icon)
text
- label appearing on the buttonicon
- image appearing on the buttonMethod Detail |
---|
public int getState()
public Image getPressedIcon()
setPressedIcon(com.sun.dtv.lwuit.Image)
,
STATE_PRESSED
public Image getRolloverIcon()
setRolloverIcon(com.sun.dtv.lwuit.Image)
,
STATE_ROLLOVER
public void setRolloverIcon(Image rolloverIcon)
rolloverIcon
- icon to usegetRolloverIcon()
,
STATE_ROLLOVER
public void setPressedIcon(Image pressedIcon)
pressedIcon
- icon usedgetPressedIcon()
,
STATE_PRESSED
public void addActionListener(ActionListener l)
l
- implementation of the action listener interfaceremoveActionListener(com.sun.dtv.lwuit.events.ActionListener)
public void removeActionListener(ActionListener l)
l
- implementation of the action listener interfaceaddActionListener(com.sun.dtv.lwuit.events.ActionListener)
public void keyPressed(int keyCode)
Component
keyPressed
in class Component
keyCode
- the key code value to indicate a physical key.public void keyReleased(int keyCode)
Component
keyReleased
in class Component
keyCode
- the key code value to indicate a physical key.public void pointerPressed(int x, int y)
Component
pointerPressed
in class Component
x
- the pointer x coordinatey
- the pointer y coordinatepublic void pointerReleased(int x, int y)
Component
pointerReleased
in class Component
x
- the pointer x coordinatey
- the pointer y coordinatepublic void paint(Graphics g)
Component
paint
in interface Animation
paint
in interface ViewOnlyComponent
paint
in class Label
g
- the component graphics
|
Java DTV API 1.3 18-Nov-2009 |
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |