Class Choice


  extended by Object
      extended by Component
          extended by Label
              extended by Choice

public class Choice
extends Label

Choice component gives a user a predefined set of choices to choose from. Individual choices are given as Label components. During the selection the choices are placed on Flow component so normal Component layout rules (width, height and flags) apply.

Use the Component.size() and Component.get(int) to access the choices after Choice is constructed.

Whenever user changes the selected choice an ITEM_CHANGED action is performed with this Choice being the source component.

Choice has following special style customizations:

See Also:
VISIBLE, FOCUSABLE, LINEFEED, WRAP, ITEM_CHANGED, Script.actionPerformed(Shell, Component, int)

Constructor Summary
Choice(Style style, Style popupStyle)
          Constructs a new Choice component.
 
Method Summary
 int getSelected()
          Returns the index of currently selected choice.
 void setChoices(List choices, int selected)
          Sets the list of choices.
 void setSelected(int selected)
          Sets the currently selected choices.
 
Methods inherited from class Component
add, appendText, clear, find, first, get, getAction, getData, getElement, getFlags, getImage, getLocation, getParent, getShell, getSize, getStyle, getText, getViewPort, hasLinefeed, indexOf, insert, isFocusable, isShown, isVisible, isWrapping, last, operator_get, operator_set, remove, remove, repaint, set, setAction, setData, setElement, setFlags, setImage, setLocation, setPreferredHeight, setPreferredSize, setPreferredWidth, setStyle, setText, size
 
Methods inherited from class Object
toString, equals, hashCode
 
Methods inherited from
equals, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Choice

public Choice(Style style,
              Style popupStyle)
Constructs a new Choice component. Use the setChoices(List, int) to set up the collection of choices.

Parameters:
style - Style to use, the image-1, if any, from style will automatically become the image for this Choice.
popupStyle - Style for selection popup window
Method Detail

getSelected

public int getSelected()
Returns the index of currently selected choice.


setSelected

public void setSelected(int selected)
Sets the currently selected choices.

Parameters:
selected - Index of selected choice

setChoices

public void setChoices(List choices,
                       int selected)
Sets the list of choices.

Parameters:
choices - List of Label components
selected - Index of selected choice