public class ButtonSprite extends Sprite implements CommandSprite, ArmingSprite, DisableableSprite
| Modifier and Type | Field and Description |
|---|---|
static int |
NORMAL
The normal, square button style.
|
static int |
ROUNDED
The rounded button style.
|
HUD_LAYERCARDINAL_DIRECTIONS, CCW, CW, DIRECTION_COUNT, DOWN, EAST, EASTNORTHEAST, EASTSOUTHEAST, FINE_DIRECTION_COUNT, HORIZONTAL, LEFT, NONE, NORTH, NORTHEAST, NORTHNORTHEAST, NORTHNORTHWEST, NORTHWEST, RIGHT, SOUTH, SOUTHEAST, SOUTHSOUTHEAST, SOUTHSOUTHWEST, SOUTHWEST, UP, VERTICAL, WEST, WESTNORTHWEST, WESTSOUTHWEST| Constructor and Description |
|---|
ButtonSprite(Label label,
int style,
Color backgroundColor,
Color alternateColor,
String actionCommand,
Object commandArgument)
Constructs a button sprite.
|
ButtonSprite(Label label,
int style,
int arcWidth,
int arcHeight,
Color backgroundColor,
Color alternateColor,
String actionCommand,
Object commandArgument)
Constructs a button sprite.
|
| Modifier and Type | Method and Description |
|---|---|
String |
getActionCommand() |
int |
getArcHeight()
Returns the arc height for rounded buttons.
|
int |
getArcWidth()
Returns the arc width for rounded buttons.
|
Color |
getBackgroundColor()
Returns the background color of this button.
|
Object |
getCommandArgument() |
Label |
getLabel()
Returns a reference to the label displayed by this sprite.
|
int |
getStyle()
Returns the style of this button.
|
boolean |
isArmed()
Checks whether or not this button appears pressed.
|
boolean |
isEnabled() |
void |
paint(Graphics2D gfx)
Called by the appropriate manager to request that the media render itself with the given
graphics context.
|
void |
setActionCommand(String actionCommand)
Sets the action command generated by this button.
|
void |
setArcHeight(int arcHeight)
Sets the arc height for rounded buttons.
|
void |
setArcWidth(int arcWidth)
Sets the arc width for rounded buttons.
|
void |
setArmed(boolean pressed)
Render this sprite such that is is drawn "armed".
|
void |
setBackgroundColor(Color backgroundColor)
Sets the background color of this button.
|
void |
setCommandArgument(Object commandArgument)
Sets the command argument generated by this button.
|
void |
setEnabled(boolean enabled)
Sets whether or not this button is enabled.
|
void |
setStyle(int style)
Sets the style of this button.
|
void |
updateBounds()
Updates this sprite's bounds after a change to the label.
|
addSpriteObserver, cancelMove, contains, fastForward, getHeight, getOrientation, getPath, getWidth, getX, getXOffset, getY, getYOffset, hitTest, inside, intersects, isMoving, move, paintPath, pathBeginning, pathCompleted, removeSpriteObserver, setLocation, setOrientation, tick, viewLocationDidChangecontains, contains, contains, contains, getBounds, getBounds2D, getPathIterator, getPathIterator, getRenderOrder, init, intersects, intersects, invalidate, queueNotification, renderCompareTo, setRenderOrder, toStringpublic static final int NORMAL
public static final int ROUNDED
public ButtonSprite(Label label, int style, Color backgroundColor, Color alternateColor, String actionCommand, Object commandArgument)
label - the label to render on the buttonstyle - the style of button to render (NORMAL or ROUNDED)backgroundColor - the background color of the buttonalternateColor - the alternate (outline) coloractionCommand - the button's commandcommandArgument - the button's command argumentpublic ButtonSprite(Label label, int style, int arcWidth, int arcHeight, Color backgroundColor, Color alternateColor, String actionCommand, Object commandArgument)
label - the label to render on the buttonstyle - the style of button to render (NORMAL or ROUNDED)arcWidth - the width of the corner arcs for rounded buttonsarcHeight - the height of the corner arcs for rounded buttonsbackgroundColor - the background color of the buttonalternateColor - the alternate (outline) coloractionCommand - the button's commandcommandArgument - the button's command argumentpublic Label getLabel()
public void updateBounds()
public void setStyle(int style)
public int getStyle()
public void setArcWidth(int arcWidth)
public int getArcWidth()
public void setArcHeight(int arcHeight)
public int getArcHeight()
public void setBackgroundColor(Color backgroundColor)
public Color getBackgroundColor()
public void setActionCommand(String actionCommand)
public String getActionCommand()
getActionCommand in interface ActionSpritepublic void setCommandArgument(Object commandArgument)
public Object getCommandArgument()
getCommandArgument in interface CommandSpritepublic void setEnabled(boolean enabled)
public boolean isEnabled()
isEnabled in interface DisableableSpritepublic void setArmed(boolean pressed)
ArmingSpritesetArmed in interface ArmingSpritepublic boolean isArmed()
public void paint(Graphics2D gfx)
AbstractMediaCopyright © 2015. All rights reserved.