Java DTV API 1.3
18-Nov-2009

com.sun.dtv.lwuit
Class Button

java.lang.Object
  extended by com.sun.dtv.lwuit.Component
      extended by com.sun.dtv.lwuit.Label
          extended by com.sun.dtv.lwuit.Button
All Implemented Interfaces:
Animation, StyleListener, Animated, MatteEnabled, ViewOnlyComponent
Direct Known Subclasses:
CheckBox, RadioButton

public class Button
extends Label

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 com.sun.dtv.lwuit.Label
animate, getAlignment, getAnimateContent, getBaselineResizeBehavior, getGap, getGraphicContent, getHorizontalAlignment, getIcon, getInteractionState, getMatte, getScalingMode, getShiftText, getText, getTextContent, getTextLayoutManager, getTextPosition, getVerticalAlignment, isDoubleBuffered, isEndsWith3Points, isOpaque, isTickerEnabled, isTickerRunning, processEvent, setAlignment, setAnimateContent, setEndsWith3Points, setGap, setGraphicContent, setHorizontalAlignment, setIcon, setInteractionState, setMatte, setScalingMode, setShiftText, setText, setTextContent, setTextLayoutManager, setTextPosition, setTickerEnabled, setVerticalAlignment, startTicker, stopTicker
 
Methods inherited from class com.sun.dtv.lwuit.Component
addFocusListener, calcPreferredSize, contains, deinitialize, getAbsoluteX, getAbsoluteY, getAnimationMode, getBaseline, getBottomGap, getBounds, getClientProperty, getComponentForm, getDelay, getHeight, getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp, getParent, getPosition, getPreferredSize, getRepetitionMode, getScrollAnimationSpeed, getScrollX, getScrollY, getSideGap, getStyle, getUIID, getWidth, getX, getY, handlesInput, hasFocus, initialize, isEnabled, isFocusable, isFocusPainted, isInitialized, isRunning, isScrollableX, isScrollableY, isScrollVisible, isSmoothScrolling, isVisible, jumpTo, keyRepeated, longKeyPress, paintBackgrounds, paintComponent, paintComponent, pointerDragged, putClientProperty, refreshTheme, removeFocusListener, repaint, repaint, requestFocus, scrollRectToVisible, setAnimationMode, setCellRenderer, setDelay, setEnabled, setFocus, setFocusable, setFocusPainted, setHandlesInput, setHeight, setInitialized, setIsScrollVisible, setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp, setPreferredSize, setRepetitionMode, setScrollAnimationSpeed, setScrollX, setScrollY, setShouldCalcPreferredSize, setSize, setSmoothScrolling, setStyle, setUIID, setVisible, setWidth, setX, setY, start, stop, styleChanged, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

STATE_ROLLOVER

public static final int STATE_ROLLOVER
Indicates the rollover state of a button which is equivalent to focused for most uses.

See Also:
Constant Field Values

STATE_PRESSED

public static final int STATE_PRESSED
Indicates the pressed state of a button.

See Also:
Constant Field Values

STATE_DEFAULT

public static final int STATE_DEFAULT
Indicates the default state of a button which is neither pressed nor focused.

See Also:
Constant Field Values
Constructor Detail

Button

public Button()
Constructs a button with an empty string for its text.


Button

public Button(String text)
Constructs a button with the specified text.

Parameters:
text - label appearing on the button

Button

public Button(Command cmd)
Allows binding a command to a button for ease of use.

Parameters:
cmd - command whose text would be used for the button and would receive action events from the button

Button

public Button(Image icon)
Constructs a button with the specified image.

Parameters:
icon - appearing on the button

Button

public Button(String text,
              Image icon)
Constructor a button with text and image.

Parameters:
text - label appearing on the button
icon - image appearing on the button
Method Detail

getState

public int getState()
Returns the button state.

Returns:
One of STATE_ROLLOVER, STATE_DEAFULT, STATE_PRESSED

getPressedIcon

public Image getPressedIcon()
Indicates the icon that is displayed on the button when the button is in pressed state.

Returns:
icon used
See Also:
setPressedIcon(com.sun.dtv.lwuit.Image), STATE_PRESSED

getRolloverIcon

public Image getRolloverIcon()
Indicates the icon that is displayed on the button when the button is in rolled over state.

Returns:
icon used
See Also:
setRolloverIcon(com.sun.dtv.lwuit.Image), STATE_ROLLOVER

setRolloverIcon

public void setRolloverIcon(Image rolloverIcon)
Indicates the icon that is displayed on the button when the button is in rolled over state.

Parameters:
rolloverIcon - icon to use
See Also:
getRolloverIcon(), STATE_ROLLOVER

setPressedIcon

public void setPressedIcon(Image pressedIcon)
Indicates the icon that is displayed on the button when the button is in pressed state.

Parameters:
pressedIcon - icon used
See Also:
getPressedIcon(), STATE_PRESSED

addActionListener

public void addActionListener(ActionListener l)
Adds a listener to the button which will cause an event to dispatch on click.

Parameters:
l - implementation of the action listener interface
See Also:
removeActionListener(com.sun.dtv.lwuit.events.ActionListener)

removeActionListener

public void removeActionListener(ActionListener l)
Removes the given action listener from the button.

Parameters:
l - implementation of the action listener interface
See Also:
addActionListener(com.sun.dtv.lwuit.events.ActionListener)

keyPressed

public void keyPressed(int keyCode)
Description copied from class: Component
If this Component is focused, the key pressed event will call this method.

Overrides:
keyPressed in class Component
Parameters:
keyCode - the key code value to indicate a physical key.

keyReleased

public void keyReleased(int keyCode)
Description copied from class: Component
If this Component is focused, the key released event will call this method.

Overrides:
keyReleased in class Component
Parameters:
keyCode - the key code value to indicate a physical key.

pointerPressed

public void pointerPressed(int x,
                           int y)
Description copied from class: Component
If this Component is focused, the pointer pressed event will call this method.

Overrides:
pointerPressed in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate

pointerReleased

public void pointerReleased(int x,
                            int y)
Description copied from class: Component
If this Component is focused, the pointer released event will call this method.

Overrides:
pointerReleased in class Component
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate

paint

public void paint(Graphics g)
Description copied from class: Component
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.

Specified by:
paint in interface Animation
Specified by:
paint in interface ViewOnlyComponent
Overrides:
paint in class Label
Parameters:
g - the component graphics

Java DTV API 1.3
18-Nov-2009

Copyright © 2008-2009 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, California 95054, U.S.A. All rights reserved.

U.S. Government Rights - Commercial software. Government users are subject to the Sun Microsystems, Inc. standard license agreement and applicable provisions of the FAR and its supplements. Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered trademarks of Sun Microsystems, Inc. in the U.S. and other countries.Products covered by and information contained in this service manual are controlled by U.S. Export Control laws and may be subject to the export or import laws in other countries. Nuclear, missile, chemical biological weapons or nuclear maritime end uses or end users, whether direct or indirect, are strictly prohibited. Export or reexport to countries subject to U.S. embargo or to entities identified on U.S. export exclusion lists, including, but not limited to, the denied persons and specially designated nationals lists is strictly prohibited.

DOCUMENTATION IS PROVIDED AS IS AND ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE DISCLAIMED, EXCEPT TO THE EXTENT THAT SUCH DISCLAIMERS ARE HELD TO BE LEGALLY INVALID.

Use of this document is subject to license terms.