public class DBListBox extends ListBox
Note: the color used in the setBackground method will be used in the scrollbar only. The background color of the control will be a lighter version of the given color.
Note: this is a special version for the LitebaseConnection. It accepts a String matrix as the input, and does not allow add/remove/set of elements, since it reflects the database and must be filled again after some row is updated.
Here is an example showing how it can be used:
import litebase.ui.*; import litebase.*; public class MyProgram extends totalcross.ui.MainWindow { DBListBox lb; public void initUI() { ResultSet rs = driver.executeQuery("select rowid,name from person where name > 20"); rs.first(); lb = new DBListBox(rs.getStrings(-1,true,false),1); // display column 1 add(lb,LEFT,TOP); } public void onEvent(totalcross.ui.event.Event event) { switch (event.type) { case totalcross.ui.event.ControlEvent.PRESSED: if (event.target == lb) String[] element = (String[])lb.getSelectedItem(); // in most cases, this is just a String and may be casted to such } } }The first item has index 0.
ListBox.CustomDrawingItem, ListBox.IconItem
Control.TranslucentShape
Modifier and Type | Field and Description |
---|---|
protected java.lang.String[][] |
sitems
The String items
|
autoResizeIcon, back0, back1, btnX, btnX0, customCursorColor, dataCol, DEFAULT_ITEM_HEIGHT_FACTOR, drawBorder, EXTRA_HEIGHT_FACTOR, extraHorizScrollButtonHeight, flick, iconGap, iconSize, ihFactor, ihtBackColors, ihtForeColors, itemCount, itemHeightFactor, items, offset, paddingBottom, paddingLeft, paddingRight, paddingTop, sbar, selectedIndex, simpleBorder, tempSelectedIndex, useFullWidthOnSelection, visibleItems, visibleLines, xOffset
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 |
---|
DBListBox()
Creates an empty Listbox.
|
DBListBox(java.lang.String[][] items,
int displayCol)
Creates a Listbox with the given items.
|
Modifier and Type | Method and Description |
---|---|
void |
add(Control control)
Does nothing
|
void |
add(java.lang.Object item)
REPLACES the current items with the given ones.
|
void |
add(java.lang.Object[] items)
REPLACES the current items with the given ones.
|
protected void |
drawItem(Graphics g,
int index,
int dx,
int dy)
You can extend ListBox and overide this method to draw the items
|
protected void |
find(char c)
Does nothing
|
int |
getColumnCount()
Returns the number of columns, if there are items.
|
java.lang.Object |
getItemAt(int i)
Get the Object at the given Index.
|
java.lang.Object[] |
getItems()
Returns all items in this ListBox.
|
protected java.lang.Object[] |
getItemsArray()
Used internally
|
protected int |
getItemWidth(int index)
Returns the width of the given item index with the current fontmetrics.
|
int |
getSelectedIndex()
Returns the position of the selected item of the Listbox or -1 if the listbox has no selected index yet.
|
java.lang.Object |
getSelectedItem()
Returns the selected item of the Listbox or null if none is selected
|
java.lang.String |
getText()
Returns the string of the selected item or "" if none is selected.
|
int |
indexOf(java.lang.Object name,
int col)
Returns the index of the object at the given column.
|
void |
insert(java.lang.Object item,
int index)
Does nothing
|
void |
qsort()
Sorts the elements of this ListBox.
|
void |
remove(Control control)
Does nothing
|
void |
remove(int itemIndex)
Does nothing
|
void |
remove(java.lang.Object item)
Does nothing
|
void |
removeAll()
Empties this ListBox, setting all elements of the array to
null
so they can be garbage collected. |
void |
setDisplayCol(int displayCol)
Sets the column of the String matrix that will be used to display the
elements.
|
void |
setItemAt(int i,
java.lang.Object s)
Does nothing
|
void |
setSelectedIndex(int i)
Select an item and scroll to it if necessary.
|
int |
size()
Returns the number of items
|
add, addWrapping, canScrollContent, clear, drawCursor, drawItems, drawSelectedItem, drawSelectedItem, enableHorizontalScroll, endSelection, flickEnded, flickStarted, getCursorColor, getEffectH, getEffectW, getEffectX, getEffectY, getFlick, getFocusableControls, getItemHeight, getPreferredHeight, getPreferredWidth, getScrollPosition, handleGeographicalFocusChangeKeys, handleSelection, hasIconItemLeft, hasIconItemRight, hideScrollBarIfNotNeeded, indexOf, leftReached, onBoundsChanged, onColorsChanged, onEvent, onPaint, qsort, scrollContent, selectLast, selectLast, setCursorColor, setEnabled, setSelectedIndex, setSelectedItem, setSelectedItemStartingWith, setSimpleBorder, setTextAreaClip, wasScrolled
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, 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, 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, onFontChanged, 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, setNinePatch, setRect, setRect, setRect, setRect, setSet, setTextShadowColor, setTranslucent, setVisible, showTip, takeInitialScreenShot, takeScreenShot, translateFromOrigin, uiStyleChanged, updateScreen, updateTemporary, willOpenKeyboard
public DBListBox()
public DBListBox(java.lang.String[][] items, int displayCol)
public void setDisplayCol(int displayCol)
public int getColumnCount()
public void add(java.lang.Object[] items)
public void add(java.lang.Object item)
public void insert(java.lang.Object item, int index)
public void removeAll()
null
so they can be garbage collected.
Attention! If you used the same object array
to initialize two ListBoxes (or ComboBoxes), this method will null both ListBoxes
('cos they use the same array reference),
and you'll get a null pointer exception!public void setItemAt(int i, java.lang.Object s)
public java.lang.Object getItemAt(int i)
public java.lang.Object getSelectedItem()
getSelectedItem
in class ListBox
public int getSelectedIndex()
getSelectedIndex
in class ListBox
public java.lang.Object[] getItems()
protected java.lang.Object[] getItemsArray()
ListBox
getItemsArray
in class ListBox
public int indexOf(java.lang.Object name, int col)
public void setSelectedIndex(int i)
setSelectedIndex
in class ListBox
protected void drawItem(Graphics g, int index, int dx, int dy)
protected int getItemWidth(int index)
getItemWidth
in class ListBox
public void qsort()