com.threerings.opengl.gui
Class Button

java.lang.Object
  extended by com.threerings.opengl.gui.Component
      extended by com.threerings.opengl.gui.TextComponent
          extended by com.threerings.opengl.gui.Label
              extended by com.threerings.opengl.gui.Button
All Implemented Interfaces:
ConfigUpdateListener<ManagedConfig>, UIConstants
Direct Known Subclasses:
CommandButton, ToggleButton

public class Button
extends Label
implements UIConstants

Displays a simple button that can be depressed and which generates an action event when pressed and released.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.threerings.opengl.gui.Label
Label.Fit
 
Field Summary
static int DOWN
          Indicates that this button is in the down state.
 
Fields inherited from class com.threerings.opengl.gui.Component
DEFAULT, DISABLED, HOVER
 
Fields inherited from interface com.threerings.opengl.gui.UIConstants
BOTTOM, CENTER, DEFAULT_SIZE, DEFAULT_SPACING, GLOW, HORIZONTAL, LEFT, NORMAL, OUTLINE, OVERLAPPING, PLAIN, RIGHT, SHADOW, TOP, VERTICAL
 
Constructor Summary
Button(GlContext ctx, Icon icon, ActionListener listener, String action)
          Creates a button with the specified icon and action.
Button(GlContext ctx, Icon icon, ActionListener listener, String action, Object argument)
          Creates a button with the specified icon, action, and argument.
Button(GlContext ctx, Icon icon, String action)
          Creates a button with the specified icon and action.
Button(GlContext ctx, Icon icon, String action, Object argument)
          Creates a button with the specified icon, action, and argument.
Button(GlContext ctx, String text)
          Creates a button with the specified textual label.
Button(GlContext ctx, String text, ActionListener listener, String action)
          Creates a button with the specified label and action.
Button(GlContext ctx, String text, ActionListener listener, String action, Object argument)
          Creates a button with the specified label, action, and argument.
Button(GlContext ctx, String text, String action)
          Creates a button with the specified label and action.
Button(GlContext ctx, String text, String action, Object argument)
          Creates a button with the specified label, action, and argument.
 
Method Summary
 boolean dispatchEvent(Event event)
          Instructs this component to process the supplied event.
 void doClick()
          Programmatically activates the button.
 String getAction()
          Returns the action generated when this button is clicked.
 Object getArgument()
          Get the argument dispatched by this button.
 String getFeedbackSound()
          Returns a reference to the feedback sound used by this component.
 int getState()
          Returns the state of this component, either Component.DEFAULT or Component.DISABLED.
 void setAction(String action)
          Configures the action to be generated when this button is clicked.
 void setArgument(Object argument)
          Set the argument dispatched by this button.
 
Methods inherited from class com.threerings.opengl.gui.Label
getFit, getIcon, getIconTextGap, getLabelRenderer, getText, setFit, setIcon, setIconTextGap, setOrientation, setPreferredWidth, setText, setTextRotation
 
Methods inherited from class com.threerings.opengl.gui.TextComponent
getEffectColor, getEffectSize, getHorizontalAlignment, getLineSpacing, getTextEffect, getTextFactory, getVerticalAlignment
 
Methods inherited from class com.threerings.opengl.gui.Component
acceptsFocus, addListener, boundsToString, configUpdated, contains, createDefaultTooltipComponent, createDefaultTooltipComponent, getAbsoluteX, getAbsoluteY, getAlpha, getBackground, getBorder, getBounds, getColor, getContext, getCursor, getFocusTarget, getHeight, getHitComponent, getInsets, getParent, getPreferredSize, getProperty, getStyleConfigs, getTooltipText, getTooltipTimeout, getTooltipWindowStyle, getTransferHandler, getWidth, getX, getY, hasFocus, invalidate, isAdded, isEnabled, isHoverable, isShowing, isTooltipRelativeToMouse, isValid, isVisible, removeAllListeners, removeAllListeners, removeListener, render, requestFocus, scrollRectToVisible, setAlpha, setBackground, setBounds, setCursor, setEnabled, setHoverable, setLocation, setParent, setPreferredSize, setPreferredSize, setProperty, setSize, setStyleConfig, setStyleConfig, setStyleConfig, setStyleConfigs, setTooltipRelativeToMouse, setTooltipText, setTransferHandler, setVisible, validate
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DOWN

public static final int DOWN
Indicates that this button is in the down state.

See Also:
Constant Field Values
Constructor Detail

Button

public Button(GlContext ctx,
              String text)
Creates a button with the specified textual label.


Button

public Button(GlContext ctx,
              String text,
              String action)
Creates a button with the specified label and action. The action will be dispatched via an ActionEvent when the button is clicked.


Button

public Button(GlContext ctx,
              String text,
              String action,
              Object argument)
Creates a button with the specified label, action, and argument.


Button

public Button(GlContext ctx,
              String text,
              ActionListener listener,
              String action)
Creates a button with the specified label and action. The action will be dispatched via an ActionEvent to the specified ActionListener when the button is clicked.


Button

public Button(GlContext ctx,
              String text,
              ActionListener listener,
              String action,
              Object argument)
Creates a button with the specified label, action, and argument.


Button

public Button(GlContext ctx,
              Icon icon,
              String action)
Creates a button with the specified icon and action. The action will be dispatched via an ActionEvent when the button is clicked.


Button

public Button(GlContext ctx,
              Icon icon,
              String action,
              Object argument)
Creates a button with the specified icon, action, and argument.


Button

public Button(GlContext ctx,
              Icon icon,
              ActionListener listener,
              String action)
Creates a button with the specified icon and action. The action will be dispatched via an ActionEvent to the specified ActionListener when the button is clicked.


Button

public Button(GlContext ctx,
              Icon icon,
              ActionListener listener,
              String action,
              Object argument)
Creates a button with the specified icon, action, and argument.

Method Detail

setAction

public void setAction(String action)
Configures the action to be generated when this button is clicked.


getAction

public String getAction()
Returns the action generated when this button is clicked.


setArgument

public void setArgument(Object argument)
Set the argument dispatched by this button.


getArgument

public Object getArgument()
Get the argument dispatched by this button.


getFeedbackSound

public String getFeedbackSound()
Returns a reference to the feedback sound used by this component.


doClick

public void doClick()
Programmatically activates the button.


getState

public int getState()
Description copied from class: Component
Returns the state of this component, either Component.DEFAULT or Component.DISABLED.

Overrides:
getState in class Component

dispatchEvent

public boolean dispatchEvent(Event event)
Description copied from class: Component
Instructs this component to process the supplied event. If the event is not processed, it will be passed up to its parent component for processing. Derived classes should thus only call super.dispatchEvent for events that they did not "consume".

Overrides:
dispatchEvent in class Component
Returns:
true if this event was consumed, false if not.


Copyright © 2011. All Rights Reserved.