com.threerings.opengl.gui
Class ComboBox

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.ComboBox
All Implemented Interfaces:
ConfigUpdateListener<ManagedConfig>, Selectable<Object>, UIConstants

public class ComboBox
extends Label
implements Selectable<Object>

Displays a selected value and allows that value to be changed by selecting from a popup menu.


Nested Class Summary
static class ComboBox.Item
          Used for displaying a label that is associated with a particular non-displayable value.
 
Nested classes/interfaces inherited from class com.threerings.opengl.gui.Label
Label.Fit
 
Field Summary
 
Fields inherited from class com.threerings.opengl.gui.Component
DEFAULT, DISABLED, HOVER
 
Fields inherited from interface com.threerings.opengl.gui.Selectable
SELECT
 
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
ComboBox(GlContext ctx)
          Creates an empty combo box.
ComboBox(GlContext ctx, Iterable<?> items)
          Creates a combo box with the supplied set of items.
ComboBox(GlContext ctx, Object[] items)
          Creates a combo box with the supplied set of items.
 
Method Summary
 void addItem(int index, Object item)
          Inserts an item into our list of items at the specified position (zero being before all other items and so forth).
 void addItem(Object item)
          Appends an item to our list of items.
 void clearItems()
          Removes all items from this combo box.
 boolean dispatchEvent(Event event)
          Instructs this component to process the supplied event.
 Object getItem(int index)
          Returns the item at the specified index.
 int getItemCount()
          Returns the number of items in this combo box.
 Object getSelected()
          Get the selected item, if any.
 int getSelectedIndex()
          Get the index of the selected item, or -1.
 Object getSelectedItem()
          Deprecated. 
 Object getSelectedValue()
          Requires that the combo box be configured with ComboBox.Item items, returns the ComboBox.Item.value of the currently selected item.
 Object getValue(int index)
          Returns the value at the specified index, the item must be an instance of ComboBox.Item.
 void selectItem(int index)
          Deprecated. 
 void selectItem(Object item)
          Deprecated. 
 void selectValue(Object value)
          Requires that the combo box be configured with ComboBox.Item items, selects the item with a ComboBox.Item.value equal to the supplied value.
 void setItems(Iterable<?> items)
          Replaces any existing items in this combo box with the supplied items.
 void setItems(Object[] items)
          Replaces any existing items in this combo box with the supplied items.
 void setPreferredDimensions(int rows, int columns)
          Sets the preferred number of columns in the popup menu.
 void setSelected(Object item)
          Set the selected item.
 void setSelectedIndex(int index)
          Set the index of the selected item.
 
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, getState, 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
 

Constructor Detail

ComboBox

public ComboBox(GlContext ctx)
Creates an empty combo box.


ComboBox

public ComboBox(GlContext ctx,
                Object[] items)
Creates a combo box with the supplied set of items. The result of Object.toString() for each item will be displayed in the list.


ComboBox

public ComboBox(GlContext ctx,
                Iterable<?> items)
Creates a combo box with the supplied set of items. The result of Object.toString() for each item will be displayed in the list.

Method Detail

addItem

public void addItem(Object item)
Appends an item to our list of items. The result of Object.toString() for the item will be displayed in the list.


addItem

public void addItem(int index,
                    Object item)
Inserts an item into our list of items at the specified position (zero being before all other items and so forth). The result of Object.toString() for the item will be displayed in the list.


setItems

public void setItems(Iterable<?> items)
Replaces any existing items in this combo box with the supplied items.


setItems

public void setItems(Object[] items)
Replaces any existing items in this combo box with the supplied items.


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 item)
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>

getSelectedItem

@Deprecated
public Object getSelectedItem()
Deprecated. 


getSelectedValue

public Object getSelectedValue()
Requires that the combo box be configured with ComboBox.Item items, returns the ComboBox.Item.value of the currently selected item.


selectItem

@Deprecated
public void selectItem(int index)
Deprecated. 


selectItem

@Deprecated
public void selectItem(Object item)
Deprecated. 


selectValue

public void selectValue(Object value)
Requires that the combo box be configured with ComboBox.Item items, selects the item with a ComboBox.Item.value equal to the supplied value.


getItemCount

public int getItemCount()
Returns the number of items in this combo box.


getItem

public Object getItem(int index)
Returns the item at the specified index.


getValue

public Object getValue(int index)
Returns the value at the specified index, the item must be an instance of ComboBox.Item.


clearItems

public void clearItems()
Removes all items from this combo box.


setPreferredDimensions

public void setPreferredDimensions(int rows,
                                   int columns)
Sets the preferred number of columns in the popup menu.


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.