com.threerings.opengl.gui
Class ToggleButton

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
                  extended by com.threerings.opengl.gui.ToggleButton
All Implemented Interfaces:
ConfigUpdateListener<ManagedConfig>, UIConstants
Direct Known Subclasses:
CheckBox

public class ToggleButton
extends Button

Like a Button except that it toggles between two states (selected and normal) when clicked.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.threerings.opengl.gui.Label
Label.Fit
 
Field Summary
static int DISSELECTED
          Indicates that this button is in the selected state and is disabled.
static int HOVER_SELECTED
          Indicates that this button is in the selected state and hovered.
static int SELECTED
          Indicates that this button is in the selected state.
 
Fields inherited from class com.threerings.opengl.gui.Button
DOWN
 
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
ToggleButton(GlContext ctx, Icon icon, String action)
          Creates a button with the specified icon and action.
ToggleButton(GlContext ctx, String text)
          Creates a button with the specified textual label.
ToggleButton(GlContext ctx, String text, String action)
          Creates a button with the specified label and action.
 
Method Summary
 int getState()
          Returns the state of this component, either Component.DEFAULT or Component.DISABLED.
 boolean isSelected()
          Returns whether or not this button is in the selected state.
 void setSelected(boolean selected)
          Configures the selected state of this button.
 
Methods inherited from class com.threerings.opengl.gui.Button
dispatchEvent, doClick, getAction, getArgument, getFeedbackSound, setAction, setArgument
 
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

SELECTED

public static final int SELECTED
Indicates that this button is in the selected state.

See Also:
Constant Field Values

HOVER_SELECTED

public static final int HOVER_SELECTED
Indicates that this button is in the selected state and hovered.

See Also:
Constant Field Values

DISSELECTED

public static final int DISSELECTED
Indicates that this button is in the selected state and is disabled.

See Also:
Constant Field Values
Constructor Detail

ToggleButton

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


ToggleButton

public ToggleButton(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 changes state.


ToggleButton

public ToggleButton(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 changes state.

Method Detail

isSelected

public boolean isSelected()
Returns whether or not this button is in the selected state.


setSelected

public void setSelected(boolean selected)
Configures the selected state of this 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 Button


Copyright © 2011. All Rights Reserved.