com.sun.lwuit
Class ComboBox

java.lang.Object
  extended by com.sun.lwuit.Component
      extended by com.sun.lwuit.List
          extended by com.sun.lwuit.ComboBox
All Implemented Interfaces:
Animation, StyleListener

public class ComboBox
extends List

A combo box is a list that allows only one selection at a time, when a user clicks the combo box a popup button with the full list of elements allows the selection of a single element. The combo box is driven by the list model and allows all the renderer features of the List as well.

Author:
Chen Fishbein
See Also:
List

Field Summary
 
Fields inherited from class com.sun.lwuit.List
FIXED_CENTER, FIXED_LEAD, FIXED_NONE, FIXED_NONE_CYCLIC, FIXED_NONE_ONE_ELEMENT_MARGIN_FROM_EDGE, FIXED_TRAIL, HORIZONTAL, VERTICAL
 
Fields inherited from class com.sun.lwuit.Component
BOTTOM, BRB_CENTER_OFFSET, BRB_CONSTANT_ASCENT, BRB_CONSTANT_DESCENT, BRB_OTHER, CENTER, LEFT, RIGHT, TOP
 
Constructor Summary
ComboBox()
          Constructs an empty combo box
ComboBox(ListModel model)
          Creates a new instance of ComboBox
ComboBox(java.lang.Object[] items)
          Creates a new instance of ComboBox
ComboBox(java.util.Vector items)
          Creates a new instance of ComboBox
 
Method Summary
protected  Dimension calcPreferredSize()
          Calculates the preferred size based on component content.
protected  Dialog createPopupDialog(List l)
          Subclasses can override this method to change the creation of the dialog
protected  List createPopupList()
          Creates the list object used within the popup dialog.
protected  void fireClicked()
          When working in 3 softbutton mode "fire" key (center softbutton) is sent to this method in order to allow 3 button devices to work properly.
 int getBaseline(int width, int height)
          The baseline for the component text according to which it should be aligned with other components for best visual look.
 int getOrientation()
          Returns the list orientation
protected  Rectangle getVisibleBounds()
          Returns the component bounds for scrolling which might differ from the getBounds for large components e.g. list.
static boolean isDefaultIncludeSelectCancel()
          Indicates whethe the soft buttons for select/cancel should appear for the combo box by default
 boolean isIncludeSelectCancel()
          Indicates whethe the soft buttons for select/cancel should appear for the combo box
 void keyReleased(int keyCode)
          If this Component is focused, the key released event will call this method
protected  void laidOut()
          This is a callback method to inform the Component when it's been laidout on the parent Container
 void paint(Graphics g)
          This method paints the Component on the screen, it should be overriden by subclasses to perform custom drawing or invoke the UI API's to let the PLAF perform the rendering.
 void pointerHover(int[] x, int[] y)
          Invoked for devices where the pointer can hover without actually clicking the display.
 void pointerHoverReleased(int[] x, int[] y)
          Invoked for devices where the pointer can hover without actually clicking the display.
 void pointerPressed(int x, int y)
          If this Component is focused, the pointer pressed event will call this method
 void pointerReleased(int x, int y)
          If this Component is focused, the pointer released event will call this method
static void setDefaultIncludeSelectCancel(boolean aDefaultIncludeSelectCancel)
          Indicates whethe the soft buttons for select/cancel should appear for the combo box by default
 void setIncludeSelectCancel(boolean includeSelectCancel)
          Indicates whethe the soft buttons for select/cancel should appear for the combo box
 void setSelectedIndex(int selection)
          Sets the current selected offset in the list, by default this implementation will scroll the list to the selection if the selection is outside of the screen
 void setSelectedIndex(int selection, boolean scroll)
          Sets the current selected offset in the list
 void setUIID(java.lang.String uiid)
          This method sets the Component the Unique identifier.
protected  Command showPopupDialog(Dialog popupDialog, List l)
          Shows the popup dialog for the combo box and returns the resulting command.
 
Methods inherited from class com.sun.lwuit.List
addActionListener, addItem, addSelectionListener, animate, fireActionEvent, getActionListeners, getBorderGap, getFixedSelection, getGridPosX, getGridPosY, getItemGap, getListSizeCalculationSampleCount, getMinElementHeight, getModel, getRenderer, getRenderingPrototype, getSelectedIndex, getSelectedItem, isCommandList, isDefaultFireOnClick, isDefaultIgnoreFocusComponentWhenUnfocused, isIgnoreFocusComponentWhenUnfocused, isMutableRendererBackgrounds, isNumericKeyActions, isScrollableX, isScrollableY, isSelectableInteraction, isTactileTouch, keyPressed, listSelectionChanged, longPointerPress, modelChanged, paramString, pointerDragged, refreshTheme, removeActionListener, removeSelectionListener, scrollRectToVisible, setBorderGap, setCommandList, setDefaultFireOnClick, setDefaultIgnoreFocusComponentWhenUnfocused, setFireOnClick, setFixedSelection, setHandlesInput, setIgnoreFocusComponentWhenUnfocused, setInputOnFocus, setItemGap, setListCellRenderer, setListSizeCalculationSampleCount, setMinElementHeight, setModel, setMutableRendererBackgrounds, setNumericKeyActions, setOrientation, setPaintFocusBehindList, setRenderer, setRenderingPrototype, setScrollToSelected, setSelectedItem, setShouldCalcPreferredSize, size
 
Methods inherited from class com.sun.lwuit.Component
addFocusListener, calcScrollSize, contains, deinitialize, deinitializeCustomStyle, dragInitiated, focusGained, focusLost, getAbsoluteX, getAbsoluteY, getBaselineResizeBehavior, getBorder, getBottomGap, getBounds, getClientProperty, getComponentForm, getDirtyRegion, getDisabledStyle, getHeight, getLabelForComponent, getName, getNextFocusDown, getNextFocusLeft, getNextFocusRight, getNextFocusUp, getParent, getPreferredH, getPreferredSize, getPreferredW, getPressedStyle, getPropertyNames, getPropertyTypes, getPropertyValue, getScrollAnimationSpeed, getScrollDimension, getScrollOpacity, getScrollX, getScrollY, getSelectCommandText, getSelectedStyle, getSideGap, getStyle, getUIID, getUnselectedStyle, getWidth, getX, getY, handlesInput, hasFocus, initComponent, initCustomStyle, isDragActivated, isEnabled, isFocusable, isFocusPainted, isInitialized, isRTL, isScrollable, isScrollVisible, isSmoothScrolling, isSnapToGrid, isTactileTouch, isTensileDragEnabled, isVisible, keyRepeated, longKeyPress, paintBackground, paintBackgrounds, paintBorder, paintComponent, paintComponent, paintLock, paintLockRelease, paintScrollbars, paintScrollbarX, paintScrollbarY, pointerDragged, pointerHoverPressed, pointerPressed, pointerReleased, putClientProperty, refreshTheme, removeFocusListener, repaint, repaint, requestFocus, scrollRectToVisible, scrollRectToVisible, setCellRenderer, setDirtyRegion, setDisabledStyle, setEnabled, setFocus, setFocusable, setFocusPainted, setHeight, setInitialized, setIsScrollVisible, setLabelForComponent, setName, setNextFocusDown, setNextFocusLeft, setNextFocusRight, setNextFocusUp, setPreferredH, setPreferredSize, setPreferredW, setPressedStyle, setPropertyValue, setRTL, setScrollAnimationSpeed, setScrollSize, setScrollVisible, setScrollX, setScrollY, setSelectCommandText, setSelectedStyle, setSize, setSmoothScrolling, setSnapToGrid, setStyle, setTactileTouch, setTensileDragEnabled, setUnselectedStyle, setUnSelectedStyle, setVisible, setWidth, setX, setY, styleChanged, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ComboBox

public ComboBox(java.util.Vector items)
Creates a new instance of ComboBox

Parameters:
items - set of items placed into the combo box model

ComboBox

public ComboBox(java.lang.Object[] items)
Creates a new instance of ComboBox

Parameters:
items - set of items placed into the combo box model

ComboBox

public ComboBox()
Constructs an empty combo box


ComboBox

public ComboBox(ListModel model)
Creates a new instance of ComboBox

Parameters:
model - the model for the combo box elements and selection
Method Detail

setUIID

public void setUIID(java.lang.String uiid)
Description copied from class: Component
This method sets the Component the Unique identifier. This method should be used before a component has been initialized

Overrides:
setUIID in class Component

getBaseline

public int getBaseline(int width,
                       int height)
Description copied from class: Component
The baseline for the component text according to which it should be aligned with other components for best visual look.

Overrides:
getBaseline in class Component
Parameters:
width - the component width
height - the component height
Returns:
baseline value from the top of the component

laidOut

protected void laidOut()
Description copied from class: Component
This is a callback method to inform the Component when it's been laidout on the parent Container

Overrides:
laidOut in class List

getVisibleBounds

protected Rectangle getVisibleBounds()
Description copied from class: Component
Returns the component bounds for scrolling which might differ from the getBounds for large components e.g. list.

Overrides:
getVisibleBounds in class List
Returns:
the component bounds
See Also:
Component.getX(), Component.getY()

setSelectedIndex

public void setSelectedIndex(int selection)
Description copied from class: List
Sets the current selected offset in the list, by default this implementation will scroll the list to the selection if the selection is outside of the screen

Overrides:
setSelectedIndex in class List
Parameters:
selection - the current selected offset in the list

setSelectedIndex

public void setSelectedIndex(int selection,
                             boolean scroll)
Description copied from class: List
Sets the current selected offset in the list

Overrides:
setSelectedIndex in class List
Parameters:
selection - the current selected offset in the list
scroll - indicates whether scrolling to selection should occur if the selection is outside of view

pointerHover

public void pointerHover(int[] x,
                         int[] y)
Description copied from class: Component
Invoked for devices where the pointer can hover without actually clicking the display. This is true for PC mouse pointer as well as some devices such as the BB storm.

Overrides:
pointerHover in class List
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate

pointerHoverReleased

public void pointerHoverReleased(int[] x,
                                 int[] y)
Description copied from class: Component
Invoked for devices where the pointer can hover without actually clicking the display. This is true for PC mouse pointer as well as some devices such as the BB storm.

Overrides:
pointerHoverReleased in class List
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate

createPopupDialog

protected Dialog createPopupDialog(List l)
Subclasses can override this method to change the creation of the dialog

Parameters:
l - the list of the popup
Returns:
a dialog instance

showPopupDialog

protected Command showPopupDialog(Dialog popupDialog,
                                  List l)
Shows the popup dialog for the combo box and returns the resulting command. This method can be overriden by subclasses to modify the behavior of the class.

Parameters:
popupDialog - the popup dialog
l - the list within
Returns:
the selected command

fireClicked

protected void fireClicked()
Description copied from class: Component
When working in 3 softbutton mode "fire" key (center softbutton) is sent to this method in order to allow 3 button devices to work properly. When overriding this method you should also override isSelectableInteraction to indicate that a command is placed appropriately on top of the fire key for 3 soft button phones.

Overrides:
fireClicked in class List

createPopupList

protected List createPopupList()
Creates the list object used within the popup dialog. This method allows subclasses to customize the list creation for the popup dialog shown when the combo box is pressed.

Returns:
a newly created list object used when the user presses the combo box.

keyReleased

public void keyReleased(int keyCode)
Description copied from class: Component
If this Component is focused, the key released event will call this method

Overrides:
keyReleased in class List
Parameters:
keyCode - the key code value to indicate a physical key.

pointerPressed

public void pointerPressed(int x,
                           int y)
Description copied from class: Component
If this Component is focused, the pointer pressed event will call this method

Overrides:
pointerPressed in class List
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate

pointerReleased

public void pointerReleased(int x,
                            int y)
Description copied from class: Component
If this Component is focused, the pointer released event will call this method

Overrides:
pointerReleased in class List
Parameters:
x - the pointer x coordinate
y - the pointer y coordinate

paint

public void paint(Graphics g)
Description copied from class: Component
This method paints the Component on the screen, it should be overriden by subclasses to perform custom drawing or invoke the UI API's to let the PLAF perform the rendering.

Specified by:
paint in interface Animation
Overrides:
paint in class List
Parameters:
g - the component graphics

calcPreferredSize

protected Dimension calcPreferredSize()
Description copied from class: Component
Calculates the preferred size based on component content. This method is invoked lazily by getPreferred size.

Overrides:
calcPreferredSize in class List
Returns:
the calculated preferred size based on component content

getOrientation

public int getOrientation()
Description copied from class: List
Returns the list orientation

Overrides:
getOrientation in class List
Returns:
the list orientation HORIZONTAL or VERTICAL
See Also:
List.HORIZONTAL, List.VERTICAL

isIncludeSelectCancel

public boolean isIncludeSelectCancel()
Indicates whethe the soft buttons for select/cancel should appear for the combo box

Returns:
true if the soft buttons for select/cancel should appear for the combo box

setIncludeSelectCancel

public void setIncludeSelectCancel(boolean includeSelectCancel)
Indicates whethe the soft buttons for select/cancel should appear for the combo box

Parameters:
includeSelectCancel - the new value

isDefaultIncludeSelectCancel

public static boolean isDefaultIncludeSelectCancel()
Indicates whethe the soft buttons for select/cancel should appear for the combo box by default

Returns:
true if the soft buttons for select/cancel should appear for the combo box

setDefaultIncludeSelectCancel

public static void setDefaultIncludeSelectCancel(boolean aDefaultIncludeSelectCancel)
Indicates whethe the soft buttons for select/cancel should appear for the combo box by default

Parameters:
aDefaultIncludeSelectCancel - the new value