public class ComboBox extends Container implements MaterialEffect.SideEffect, HasValue<java.lang.Object>
Note: the color used in the setBackground method will be used in the button only. The background color of the control will be a lighter version of the given color.
Control.TranslucentShape
Modifier and Type | Field and Description |
---|---|
static int |
arrowStyle |
static int |
ARROWSTYLE_DOWNDOT |
static int |
ARROWSTYLE_PAGEFLIP |
java.lang.String |
caption
The caption to draw when this ComboBox is empty.
|
int |
captionColor
The caption's color.
|
Image |
captionIcon
An optional caption's icon
|
CaptionPress |
captionPress
Handler for the CustomPress
|
int |
checkColor
The check color used to fill the radio button used in Android.
|
static int |
defaultClearValueInt
The default value that is set to the clearValueInt of all ComboBox.
|
int |
disabledColor
The disable color used to fill the background and text color when disabled.
|
boolean |
enableSearch
Parameter passed to PopupMenu.
|
boolean |
fullHeight
If set to true, the popup window will have the height of the screen
|
boolean |
fullWidth
If set to true, the popup window will have the width of the screen
|
int |
iconGap
The gap between the icon and the text.
|
int |
paddingBottom
The bottom border padding.
|
int |
paddingLeft
The padding between the left border and the text (or icon, if it's available).
|
int |
paddingRight
The padding between the right border and the arrow.
|
int |
paddingTop
The top border padding.
|
protected ComboBoxDropDown |
pop |
java.lang.String |
popupTitle
The title of the PopupMenu when in Android user interface style.
|
static boolean |
usePopupMenu
Set to false to don't use the PopupMenu when the user interface style is Android.
|
alwaysEraseBackground, BACKGROUND_CYLINDRIC_SHADED, BACKGROUND_SHADED, BACKGROUND_SHADED_INV, BACKGROUND_SOLID, backgroundStyle, BORDER_LOWERED, BORDER_NONE, BORDER_RAISED, BORDER_ROUNDED, BORDER_SIMPLE, BORDER_TOP, borderColor, borderRadius, children, controlFound, finishedStart, ignoreOnAddAgain, ignoreOnRemove, insets, lastH, lastScreenWidth, lastW, lastX, lastY, numChildren, started, tabOrder, tail, TRANSITION_TIME
AFTER, alphaValue, appId, appObj, asContainer, asWindow, backColor, BEFORE, BOTTOM, BOTTOM_OF, BRIGHTER_BACKGROUND, callListenersOnAllTargets, CENTER, CENTER_OF, clearValueInt, clearValueStr, DARKER_BACKGROUND, DP, effect, enableUpdateScreen, esce, eventsEnabled, FILL, fillColor, FIT, floating, fm, fmH, focusHandler, focusLess, focusOnPenDown, focusTraversable, font, FONTSIZE, foreColor, height, ignoreInsets, isHighlighting, isTablet, KEEP, keepDisabled, keepEnabled, LEFT, next, nextTabControl, npParts, offscreen, offscreen0, onEventFirst, parent, PARENTSIZE, PARENTSIZEMAX, PARENTSIZEMIN, PREFERRED, prev, RANGE, repositionAllowed, RIGHT, RIGHT_OF, SAME, SCREENSIZE, SCREENSIZEMAX, SCREENSIZEMIN, setFont, setH, setRel, setW, setX, SETX_NOT_SET, setY, tempW, textShadowColor, TOP, translucentShape, transparentBackground, uiAdjustmentsBasedOnFontHeightIsSupported, uiAndroid, UICONST, uiFlat, uiHolo, uiMaterial, uiVista, visible, width, WILL_RESIZE, x, y
Constructor and Description |
---|
ComboBox()
Creates an empty ComboBox
|
ComboBox(ComboBoxDropDown userPopList)
Constructs a ComboBox with the given PopList.
|
ComboBox(ListBox userListBox)
Creates a ComboBox with a PopList containing the given ListBox.
|
ComboBox(java.lang.Object[] items)
Creates a ComboBox with the given items
|
Modifier and Type | Method and Description |
---|---|
void |
add(Control control)
Does nothing
|
void |
add(java.lang.Object item)
Adds an Object to the Listbox.
|
void |
add(java.lang.Object[] items)
Adds an array of Objects to the Listbox
|
void |
add(java.lang.Object[] items,
int startAt,
int size)
Deprecated.
Use
add(Object[]) instead. |
int |
addWrapping(java.lang.String text)
Adds the given text to this ListBox, breaking the text if it goes beyond the ListBox' limits, and also breaking if it contains \n.
|
void |
clear()
Clears this control, selecting index clearValueInt (0 by default); uses clearValueStr if set, instead.
|
protected void |
drawSelectedItem(Graphics g) |
void |
enableHorizontalScroll()
Adds support for horizontal scroll on this listbox.
|
boolean |
equals(java.lang.Object o) |
protected int |
getArrowColor()
Used to determine the arrow color in Material UI when its drawing.
|
void |
getFocusableControls(Vector v)
Get a list of child controls of this container which are focus candidates
|
java.lang.Object |
getItemAt(int i)
Get the Object at the given Index
|
java.lang.Object[] |
getItems()
Returns all items in this ComboBox
|
ListBox |
getListBox()
Returns the ListBox used when this combobox is opened.
|
int |
getPreferredHeight()
Returns the preferred height of this control.
|
int |
getPreferredWidth()
Returns the preferred width of this control.
|
int |
getSelectedIndex()
Returns the position of the selected item of the ListBox
|
java.lang.Object |
getSelectedItem()
Returns the selected item of the ListBox
|
java.lang.Object |
getValue() |
Control |
handleGeographicalFocusChangeKeys(KeyEvent ke)
Used by the main event loop to give the currently focused control an opportunity to act directly on
the KeyEvent.
|
int |
indexOf(java.lang.Object name)
Returns the index of the item specified by the name
|
void |
insert(java.lang.Object item,
int index)
Adds an Object to the Listbox at the given index
|
protected void |
onBoundsChanged(boolean screenChanged)
Called after a setRect.
|
protected void |
onColorsChanged(boolean colorsChanged)
Called after a setEnabled, setForeColor and setBackColor and when a control has
been added to a Container.
|
void |
onEvent(Event event)
Called to process key, pen, control and other posted events.
|
protected void |
onFontChanged()
Passes the font to the pop list
|
void |
onPaint(Graphics g)
paint the combo's border and the current selected item
|
void |
popup()
Pops up the ComboBoxDropDown
|
void |
qsort()
Sorts the items of this combobox, and then unselects the current item.
|
void |
qsort(boolean caseless)
Sorts the elements of this ListBox.
|
void |
remove(Control control)
Does nothing
|
void |
remove(int itemIndex)
Removes an Object from the Listbox at the given index.
|
void |
remove(java.lang.Object item)
Removes an Object from the Listbox
|
void |
removeAll()
Empties the ListBox
|
void |
selectLast()
Selects the last item added to this combobox, doing a scroll if needed.
|
void |
setBackForeItemColors(IntHashtable ihtFore,
IntHashtable ihtBack)
Sets the ihtForeColors and ihtBackColors for the ListBox used with this ComboBox.
|
void |
setCursorColor(int color)
Sets the cursor color for this ComboBox.
|
void |
setItemAt(int i,
java.lang.Object s)
Sets the Object at the given Index, starting from 0
|
void |
setNinePatch(Image img,
int corner,
int side)
Set the NinePatch of the control.
|
void |
setPop(ComboBoxDropDown lb)
Replaces the original ComboBoxDropDown by the given one.
|
void |
setSelectedIndex(int i)
Select the given index.
|
void |
setSelectedIndex(int i,
boolean sendPressEvent)
Select the given index, and optionally sends a PRESSED event.
|
void |
setSelectedItem(java.lang.Object name)
Selects an item.
|
void |
setSelectedItem(java.lang.Object name,
boolean sendPress)
Selects an item.
|
boolean |
setSelectedItemStartingWith(java.lang.String text,
boolean caseInsensitive)
Selects the item that starts with the given text
|
boolean |
setSelectedItemStartingWith(java.lang.String text,
boolean caseInsensitive,
boolean sendPress)
Selects the item that starts with the given text
|
void |
setValue(java.lang.Object value) |
void |
sidePaint(Graphics g,
int alpha) |
void |
sideStart() |
void |
sideStop() |
int |
size()
Returns the number of items
|
void |
unpop()
Unpops the ComboBoxDropDown.
|
protected void |
updatePopRect() |
add, add, add, add, broadcastEvent, fillBackground, findChild, findNearestChild, findNextFocusControl, getBorderRadius, getBorderStyle, getChildren, getChildrenCount, getClientRect, getClientRect, getFirstChild, getInsets, incLastX, incLastY, initUI, isPressed, moveFocusToNextControl, moveFocusToNextEditable, onAddAgain, onRemove, onSwapFinished, paintChildren, resize, resizeHeight, resizeWidth, setBorderRadius, setBorderStyle, setEnabled, setFocusTraversable, setHighlighting, setInsets, setPressColor, setPressed, swapToTopmostWindow
_onEvent, addEnabledStateListener, addFocusListener, addFontChangeHandler, addGridListener, addHandler, addHighlightListener, addKeyListener, addListContainerListener, addMouseListener, addMultiTouchListener, addPenListener, addPressListener, addPushNotificationListener, addSizeChangeHandler, addTimer, addTimer, addTimerListener, addValueChangeHandler, addWindowListener, bringToFront, changeHighlighted, contains, drawTranslucentBackground, getAbsoluteRect, getBackColor, getDoEffect, getEffectH, getEffectW, getEffectX, getEffectY, getEventListeners, getFont, getForeColor, getGap, getGraphics, getHeight, getNext, getParent, getParentWindow, getPos, getPressedEvent, getPrev, getRect, getSize, getTextShadowColor, getWidth, getX, getX2, getY, getY2, hadParentScrolled, hasFocus, internalSetEnabled, intXYWH, isActionEvent, isChildOf, isDisplayed, isEnabled, isFloating, isInsideOrNear, isObscured, isTopMost, isVisible, isVisibleAndInside, onWindowPaintFinished, post, postEvent, postPressedEvent, releaseScreenShot, removeEnabledStateListener, removeFocusListener, removeGridListener, removeHandler, removeHighlightListener, removeKeyListener, removeListContainerListener, removeMouseListener, removeMultiTouchListener, removePenListener, removePressListener, removePushNotificationListener, removeTimer, removeTimerListener, removeWindowListener, repaint, repaintNow, reposition, reposition, repositionChildren, requestFocus, resetSetPositions, resetStyle, safeRepaintNow, safeUpdateScreen, sendToBack, setBackColor, setBackForeColors, setDoEffect, setFloating, setFocusLess, setFont, setForeColor, setNinePatch, setRect, setRect, setRect, setRect, setSet, setTextShadowColor, setTranslucent, setVisible, showTip, takeInitialScreenShot, takeScreenShot, translateFromOrigin, uiStyleChanged, updateScreen, updateTemporary, willOpenKeyboard
public static final int ARROWSTYLE_DOWNDOT
public static final int ARROWSTYLE_PAGEFLIP
public static int arrowStyle
protected ComboBoxDropDown pop
public boolean fullHeight
public boolean fullWidth
public int disabledColor
public int iconGap
public int paddingLeft
public int paddingRight
public int paddingTop
public int paddingBottom
public CaptionPress captionPress
public static int defaultClearValueInt
public int checkColor
public java.lang.String popupTitle
public boolean enableSearch
PopupMenu.enableSearch
public java.lang.String caption
captionColor
public int captionColor
public Image captionIcon
public static boolean usePopupMenu
// at the begining of your program: ComboBox.usePopupMenu = true; // when you want to create the standalone ComboBox ComboBox.usePopupMenu = false; // turn flag off .. create the ComboBox ComboBox.usePopupMenu = true; // turn flag on againAn internal copy of the flag is set at the constructor.
public ComboBox()
public ComboBox(java.lang.Object[] items)
public ComboBox(ListBox userListBox)
public ComboBox(ComboBoxDropDown userPopList)
public void add(java.lang.Object[] items)
@Deprecated public void add(java.lang.Object[] items, int startAt, int size)
add(Object[])
instead.public void add(java.lang.Object item)
add(Object[])
to add a bunch of objects instead.public int addWrapping(java.lang.String text)
add
methods.public void insert(java.lang.Object item, int index)
public void remove(java.lang.Object item)
public void remove(int itemIndex)
public void setItemAt(int i, java.lang.Object s)
public java.lang.Object getItemAt(int i)
public java.lang.Object getSelectedItem()
public int getSelectedIndex()
public java.lang.Object[] getItems()
public int indexOf(java.lang.Object name)
public void setCursorColor(int color)
public void setSelectedItem(java.lang.Object name)
public void setSelectedItem(java.lang.Object name, boolean sendPress)
public void setSelectedIndex(int i)
public void setSelectedIndex(int i, boolean sendPressEvent)
public int size()
public int getPreferredWidth()
Control
getPreferredWidth
in class Control
public void setNinePatch(Image img, int corner, int side)
Control
setNinePatch
in class Control
img
- The image to make the NinePatch.
The image must be on a NinePatch format.corner
- The size, in pixels, of the NinePatch's cornerside
- The size, in pixels, of the NinePatch's side.public int getPreferredHeight()
Control
getPreferredHeight
in class Control
protected void onFontChanged()
onFontChanged
in class Control
public void setBackForeItemColors(IntHashtable ihtFore, IntHashtable ihtBack)
protected void onBoundsChanged(boolean screenChanged)
Control
onBoundsChanged
in class Control
screenChanged
- If the bounds were changed due to a screen change (rotation, collapse)public void onEvent(Event event)
Control
protected void updatePopRect()
public void popup()
public void unpop()
protected void onColorsChanged(boolean colorsChanged)
Control
onColorsChanged
in class Container
protected int getArrowColor()
public void onPaint(Graphics g)
protected void drawSelectedItem(Graphics g)
public void qsort()
public void qsort(boolean caseless)
caseless
- Pass true to make a caseless sort, if the items are Strings.public void enableHorizontalScroll()
public void selectLast()
public void clear()
public void getFocusableControls(Vector v)
Container
getFocusableControls
in class Container
v
- A vector into which to add the focus candidates.public Control handleGeographicalFocusChangeKeys(KeyEvent ke)
Control
handleGeographicalFocusChangeKeys
in class Control
ke
- The KeyEvent to be processedSettings.geographicalFocus
public ListBox getListBox()
public boolean setSelectedItemStartingWith(java.lang.String text, boolean caseInsensitive)
text
- The text string to search forcaseInsensitive
- If true, the text and all searched strings are first converted to lowercase.public boolean setSelectedItemStartingWith(java.lang.String text, boolean caseInsensitive, boolean sendPress)
text
- The text string to search forcaseInsensitive
- If true, the text and all searched strings are first converted to lowercase.sendPress
- If true, sends the PRESSED eventpublic void setPop(ComboBoxDropDown lb)
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public void sideStart()
sideStart
in interface MaterialEffect.SideEffect
public void sideStop()
sideStop
in interface MaterialEffect.SideEffect
public void sidePaint(Graphics g, int alpha)
sidePaint
in interface MaterialEffect.SideEffect
public java.lang.Object getValue()