com.threerings.opengl.gui
Class List

java.lang.Object
  extended by com.threerings.opengl.gui.Component
      extended by com.threerings.opengl.gui.Container
          extended by com.threerings.opengl.gui.List
All Implemented Interfaces:
ConfigUpdateListener<ManagedConfig>, Selectable<Object>

public class List
extends Container
implements Selectable<Object>

Displays a list of selectable entries and fires an ActionEvent when the selected value changes. Each entry is displayed as a string obtained by calling Object.toString() on the supplied values.


Nested Class Summary
 
Nested classes/interfaces inherited from class com.threerings.opengl.gui.Container
Container.ChildOp
 
Field Summary
protected  int _selidx
          The index of the current selection (or -1 for none).
protected  ActionListener _slistener
          Listens for button selections.
protected  ArrayList<Object> _values
          The values contained in the list.
 
Fields inherited from class com.threerings.opengl.gui.Container
_children, _layout
 
Fields inherited from class com.threerings.opengl.gui.Component
_alpha, _backgrounds, _borders, _colors, _ctx, _cursor, _enabled, _height, _hover, _hoverable, _insets, _listeners, _parent, _preferredSize, _properties, _rect, _styleConfigs, _tipmouse, _tiptext, _tooltipStyle, _transferHandler, _valid, _visible, _width, _x, _y, DEFAULT, DISABLED, HOVER, STATE_COUNT, STATE_PCLASSES
 
Fields inherited from interface com.threerings.opengl.gui.Selectable
SELECT
 
Constructor Summary
List(GlContext ctx)
          Creates an empty list.
List(GlContext ctx, Object[] values)
          Creates a list and populates it with the supplied values.
 
Method Summary
 void addValue(Object value)
          Adds a value to the list.
protected  String getDefaultStyleConfig()
          Returns the name of the default config to be used for all instances of this component.
 Object getSelected()
          Get the selected item, if any.
 int getSelectedIndex()
          Get the index of the selected item, or -1.
 Object getSelectedValue()
          Deprecated. 
 boolean removeValue(Object value)
          Removes a value from the list, if it is present.
 void setSelected(Object value)
          Set the selected item.
 void setSelectedIndex(int index)
          Set the index of the selected item.
 void setSelectedValue(Object value)
          Deprecated. 
 void setValues(Object[] values)
          Sets the list's values.
 
Methods inherited from class com.threerings.opengl.gui.Container
add, add, add, add, applyOperation, computePreferredSize, getComponent, getComponentCount, getComponentIndex, getFirstDescendantFocus, getHitComponent, getLastDescendantFocus, getLayoutManager, getNextFocus, getPreviousFocus, layout, remove, remove, removeAll, renderComponent, replace, setAlpha, setEnabled, setHoverable, setLayoutManager, validate, wasAdded, wasRemoved
 
Methods inherited from class com.threerings.opengl.gui.Component
acceptsFocus, addListener, boundsToString, changeCursor, configUpdated, contains, createDefaultTooltipComponent, createDefaultTooltipComponent, createTooltipComponent, dispatchEvent, emitEvent, getAbsoluteX, getAbsoluteY, getAlpha, getBackground, getBorder, getBounds, getColor, getContext, getCursor, getFallbackState, getFocusTarget, getHeight, getInsets, getNextFocus, getParent, getPreferredSize, getPreviousFocus, getProperty, getState, getStateCount, getStatePseudoClass, getStyleConfigs, getTooltipText, getTooltipTimeout, getTooltipWindowStyle, getTransferHandler, getWidth, getWindow, getX, getY, hasFocus, intersectScissor, invalidate, isAdded, isEnabled, isHoverable, isShowing, isTooltipRelativeToMouse, isValid, isVisible, removeAllListeners, removeAllListeners, removeListener, render, renderBackground, renderBorder, requestFocus, scrollRectToVisible, scrollRectToVisible, setBackground, setBounds, setCursor, setLocation, setParent, setPreferredSize, setPreferredSize, setProperty, setSize, setStyleConfig, setStyleConfig, setStyleConfig, setStyleConfigs, setTooltipRelativeToMouse, setTooltipText, setTransferHandler, setVisible, stateDidChange, updateCursor, updateFromStyleConfig, updateFromStyleConfig
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_values

protected ArrayList<Object> _values
The values contained in the list.


_selidx

protected int _selidx
The index of the current selection (or -1 for none).


_slistener

protected ActionListener _slistener
Listens for button selections.

Constructor Detail

List

public List(GlContext ctx)
Creates an empty list.


List

public List(GlContext ctx,
            Object[] values)
Creates a list and populates it with the supplied values.

Method Detail

setValues

public void setValues(Object[] values)
Sets the list's values.


addValue

public void addValue(Object value)
Adds a value to the list.


removeValue

public boolean removeValue(Object value)
Removes a value from the list, if it is present.

Returns:
true if the value was removed, false if it was not in the list

getSelected

public Object getSelected()
Description copied from interface: Selectable
Get the selected item, if any.

Specified by:
getSelected in interface Selectable<Object>

setSelected

public void setSelected(Object value)
Description copied from interface: Selectable
Set the selected item.

Specified by:
setSelected in interface Selectable<Object>

getSelectedIndex

public int getSelectedIndex()
Description copied from interface: Selectable
Get the index of the selected item, or -1.

Specified by:
getSelectedIndex in interface Selectable<Object>

setSelectedIndex

public void setSelectedIndex(int index)
Description copied from interface: Selectable
Set the index of the selected item.

Specified by:
setSelectedIndex in interface Selectable<Object>

getSelectedValue

@Deprecated
public Object getSelectedValue()
Deprecated. 


setSelectedValue

@Deprecated
public void setSelectedValue(Object value)
Deprecated. 


getDefaultStyleConfig

protected String getDefaultStyleConfig()
Description copied from class: Component
Returns the name of the default config to be used for all instances of this component. Derived classes will likely want to override this method and set up a default config for their type of component.

Overrides:
getDefaultStyleConfig in class Container