|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.sun.lwuit.Component com.sun.lwuit.Label com.sun.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.lwuit.Component |
---|
BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, LEFT, RIGHT, TOP |
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(java.lang.String text)
Constructs a button with the specified text. |
|
Button(java.lang.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 |
boolean |
animate()
Allows the animation to reduce "repaint" calls when it returns false. |
protected Dimension |
calcPreferredSize()
Calculates the preferred size based on component content. |
protected void |
dragInitiated()
Invoked on the focus component to let it know that drag has started on the parent container for the case of a component that doesn't support scrolling |
protected void |
fireClicked()
When working in 3 softbutton mode "fire" key (center softbutton) is sent to this method in order to allow 3 button devices to work properly. |
protected Border |
getBorder()
Normally returns getStyle().getBorder() but some subclasses might use this to programmatically replace the border in runtime e.g. for a pressed border effect |
Command |
getCommand()
This method return the Button Command if exists |
Image |
getDisabledIcon()
Indicates the icon that is displayed on the button when the button is in the disabled state |
Image |
getIconFromState()
Returns the icon for the button based on its current state |
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 |
Image |
getRolloverPressedIcon()
Indicates the icon that is displayed on the button when the button is in pressed state and is selected. |
int |
getState()
Returns the button state |
boolean |
isOppositeSide()
Places the check box or radio button on the opposite side at the far end |
protected boolean |
isSelectableInteraction()
This method allows a component to indicate that it is interested in an "implicit" select command to appear in the "fire" button when 3 softbuttons are defined in a device. |
boolean |
isSelected()
Returns true if the button is selected for toggle buttons, throws an exception if this is not a toggle button |
boolean |
isToggle()
Toggle button mode is only relevant for checkboxes/radio buttons. |
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 |
keyRepeated(int keyCode)
If this Component is focused, the key repeat 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 |
pointerDragged(int x,
int y)
If this Component is focused, the pointer dragged event will call this method |
void |
pointerHover(int[] x,
int[] y)
Invoked for devices where the pointer can hover without actually clicking the display. |
void |
pointerHoverReleased(int[] x,
int[] y)
Invoked for devices where the pointer can hover without actually clicking the display. |
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 |
pressed()
Invoked to change the state of the button to the pressed state |
void |
released()
Invoked to change the state of the button to the released state |
void |
released(int x,
int y)
Invoked to change the state of the button to the released state |
void |
removeActionListener(ActionListener l)
Removes the given action listener from the button |
void |
setAlignment(int align)
Deprecated. use the Style alignment instead |
void |
setCommand(Command cmd)
Applies the given command to this button |
void |
setDisabledIcon(Image disabledIcon)
Indicates the icon that is displayed on the button when the button is in the disabled state |
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 |
void |
setRolloverPressedIcon(Image rolloverPressedIcon)
Indicates the icon that is displayed on the button when the button is in pressed state and is selected. |
void |
setToggle(boolean toggle)
Toggle button mode is only relevant for checkboxes/radio buttons. |
Methods inherited from class com.sun.lwuit.Label |
---|
getAlignment, getBaselineResizeBehavior, getGap, getIcon, getShiftText, getText, getTextPosition, getVerticalAlignment, isDefaultTickerEnabled, isEndsWith3Points, isTickerEnabled, isTickerRunning, paramString, setDefaultTickerEnabled, setEndsWith3Points, setGap, setIcon, setShiftText, setText, setTextPosition, setTickerEnabled, setVerticalAlignment, shouldTickerStart, startTicker, startTicker, stopTicker |
Methods inherited from class java.lang.Object |
---|
equals, 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(java.lang.String text)
text
- label appearing on the buttonpublic Button(Command cmd)
cmd
- command whose text would be used for the button and would recive action events
from the buttonpublic Button(Image icon)
icon
- appearing on the buttonpublic Button(java.lang.String text, Image icon)
text
- label appearing on the buttonicon
- image appearing on the buttonMethod Detail |
---|
public void setCommand(Command cmd)
cmd
- the command on the buttonpublic int getState()
public Image getPressedIcon()
STATE_PRESSED
public Image getRolloverPressedIcon()
public void setRolloverPressedIcon(Image rolloverPressedIcon)
rolloverPressedIcon
- icon usedpublic Image getDisabledIcon()
public Image getRolloverIcon()
STATE_ROLLOVER
public void setRolloverIcon(Image rolloverIcon)
rolloverIcon
- icon to useSTATE_ROLLOVER
public void setPressedIcon(Image pressedIcon)
pressedIcon
- icon usedSTATE_PRESSED
public void setDisabledIcon(Image disabledIcon)
disabledIcon
- icon usedpublic void addActionListener(ActionListener l)
l
- implementation of the action listener interfacepublic void removeActionListener(ActionListener l)
l
- implementation of the action listener interfacepublic Image getIconFromState()
public void pressed()
public void released()
public void released(int x, int y)
x
- the x position if a touch event triggered this, -1 if this isn't relevanty
- the y position if a touch event triggered this, -1 if this isn't relevantpublic 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 keyRepeated(int keyCode)
Component
keyRepeated
in class Component
keyCode
- the key code value to indicate a physical key.protected void fireClicked()
Component
fireClicked
in class Component
protected boolean isSelectableInteraction()
Component
isSelectableInteraction
in class Component
public void pointerHover(int[] x, int[] y)
Component
pointerHover
in class Component
x
- the pointer x coordinatey
- the pointer y coordinatepublic void pointerHoverReleased(int[] x, int[] y)
Component
pointerHoverReleased
in class Component
x
- the pointer x coordinatey
- the pointer y coordinatepublic 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 coordinateprotected void dragInitiated()
Component
dragInitiated
in class Component
public void pointerDragged(int x, int y)
Component
pointerDragged
in class Component
x
- the pointer x coordinatey
- the pointer y coordinatepublic void paint(Graphics g)
Component
paint
in interface Animation
paint
in class Label
g
- the component graphicsprotected Dimension calcPreferredSize()
Component
calcPreferredSize
in class Label
protected Border getBorder()
Component
getBorder
in class Component
public Command getCommand()
public boolean isSelected()
public void setAlignment(int align)
Label
setAlignment
in class Label
align
- alignment valueComponent.CENTER
,
Component.LEFT
,
Component.RIGHT
public boolean isToggle()
public void setToggle(boolean toggle)
toggle
- the toggle to setpublic boolean animate()
Animation
Display
class.
animate
in interface Animation
animate
in class Label
public boolean isOppositeSide()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |