|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectde.matthiasmann.twl.Widget
de.matthiasmann.twl.ListBox<T>
T - the data type of the list entriespublic class ListBox<T>
A list box. Supports single and multiple columns.
| Nested Class Summary | |
|---|---|
static class |
ListBox.CallbackReason
|
protected static class |
ListBox.ListBoxLabel
|
| Nested classes/interfaces inherited from class de.matthiasmann.twl.Widget |
|---|
Widget.OffscreenMouseAdjustments, Widget.RenderOffscreen |
| Field Summary | |
|---|---|
static int |
DEFAULT_CELL_HEIGHT
|
static int |
NO_SELECTION
The value returned by getSelected() to indicate that no entry is selected. |
static int |
SINGLE_COLUMN
|
| Fields inherited from class de.matthiasmann.twl.Widget |
|---|
STATE_DISABLED, STATE_HAS_FOCUSED_CHILD, STATE_HAS_OPEN_POPUPS, STATE_KEYBOARD_FOCUS |
| Constructor Summary | |
|---|---|
ListBox()
|
|
ListBox(ListModel<T> model)
|
|
ListBox(ListSelectionModel<T> model)
|
|
| Method Summary | |
|---|---|
void |
addCallback(CallbackWithReason<ListBox.CallbackReason> cb)
|
protected void |
applyTheme(ThemeInfo themeInfo)
Apply the given theme. |
protected ListBoxDisplay |
createDisplay()
|
int |
findEntryByName(java.lang.String prefix)
|
int |
getCellHeight()
|
int |
getCellWidth()
|
int |
getEntryAt(int x,
int y)
Returns the entry at the specific coordinates or -1 if there is no entry. |
int |
getFirstVisible()
|
int |
getLastVisible()
|
int |
getMinHeight()
Returns the minimum height of the widget. |
int |
getMinWidth()
Returns the minimum width of the widget. |
ListModel<T> |
getModel()
|
int |
getNumColumns()
|
int |
getNumEntries()
|
int |
getNumRows()
|
int |
getPreferredInnerHeight()
Computes the preferred inner height (the size of the widget without the border) The default implementation uses the current position of the children. |
int |
getPreferredInnerWidth()
Computes the preferred inner width (the size of the widget without the border) The default implementation uses the current position of the children. |
int |
getSelected()
|
IntegerModel |
getSelectionModel()
|
Widget |
getWidgetAt(int x,
int y)
The method always return this. |
protected void |
goKeyboard(int dir)
|
boolean |
handleEvent(Event evt)
Called when an event occurred that this widget could be interested in. |
void |
insertChild(Widget child,
int index)
Inserts a new child into this widget. |
boolean |
isFixedCellHeight()
|
boolean |
isFixedCellWidth()
|
boolean |
isRowMajor()
|
protected boolean |
isSearchChar(char ch)
|
protected void |
keyboardFocusGained()
Called when this widget has gained the keyboard focus. |
protected void |
keyboardFocusLost()
Called when this widget has lost the keyboard focus. |
protected void |
layout()
Called when the layoutInvalid flag is set. |
protected void |
paint(GUI gui)
Paints this widget and it's children. |
void |
removeAllChildren()
Removes all children of this widget. |
void |
removeCallback(CallbackWithReason<ListBox.CallbackReason> cb)
|
Widget |
removeChild(int index)
Removes the specified child from this widget. |
void |
scrollToSelected()
|
void |
setCellHeight(int cellHeight)
|
void |
setCellWidth(int cellWidth)
|
void |
setFirstVisible(int firstVisible)
|
void |
setFixedCellHeight(boolean fixedCellHeight)
|
void |
setFixedCellWidth(boolean fixedCellWidth)
|
void |
setModel(ListModel<T> model)
|
void |
setModel(ListSelectionModel<T> model)
|
void |
setRowMajor(boolean rowMajor)
|
void |
setSelected(int selected)
Selects the specified entry and scrolls to make it visible |
void |
setSelected(int selected,
boolean scroll)
Selects the specified entry and optionally scrolls to that entry |
void |
setSelectionModel(IntegerModel selectionModel)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int NO_SELECTION
getSelected() to indicate that no entry is selected.
setSelected(int),
setSelected(int, boolean),
Constant Field Valuespublic static final int DEFAULT_CELL_HEIGHT
public static final int SINGLE_COLUMN
| Constructor Detail |
|---|
public ListBox()
public ListBox(ListModel<T> model)
public ListBox(ListSelectionModel<T> model)
| Method Detail |
|---|
public ListModel<T> getModel()
public void setModel(ListModel<T> model)
public IntegerModel getSelectionModel()
public void setSelectionModel(IntegerModel selectionModel)
public void setModel(ListSelectionModel<T> model)
public void addCallback(CallbackWithReason<ListBox.CallbackReason> cb)
public void removeCallback(CallbackWithReason<ListBox.CallbackReason> cb)
public int getCellHeight()
public void setCellHeight(int cellHeight)
public int getCellWidth()
public void setCellWidth(int cellWidth)
public boolean isFixedCellHeight()
public void setFixedCellHeight(boolean fixedCellHeight)
public boolean isFixedCellWidth()
public void setFixedCellWidth(boolean fixedCellWidth)
public boolean isRowMajor()
public void setRowMajor(boolean rowMajor)
public int getFirstVisible()
public int getLastVisible()
public void setFirstVisible(int firstVisible)
public int getSelected()
public void setSelected(int selected)
selected - the index or NO_SELECTION
java.lang.IllegalArgumentException - if index is invalidsetSelected(int, boolean)
public void setSelected(int selected,
boolean scroll)
selected - the index or NO_SELECTIONscroll - true if it should scroll to make the entry visible
java.lang.IllegalArgumentException - if index is invalidpublic void scrollToSelected()
public int getNumEntries()
public int getNumRows()
public int getNumColumns()
public int findEntryByName(java.lang.String prefix)
public Widget getWidgetAt(int x,
int y)
getWidgetAt in class Widgetx - the x coordinatey - the y coordinate
public int getEntryAt(int x,
int y)
x - the x coordinatey - the y coordinate
public void insertChild(Widget child,
int index)
throws java.lang.IndexOutOfBoundsException
Widget
insertChild in class Widgetchild - the child that should be insertedindex - the index where it should be inserted
java.lang.IndexOutOfBoundsException - if the index is invalidpublic void removeAllChildren()
Widget
removeAllChildren in class WidgetWidget.allChildrenRemoved()
public Widget removeChild(int index)
throws java.lang.IndexOutOfBoundsException
Widget
removeChild in class Widgetindex - the index of the child
java.lang.IndexOutOfBoundsException - if the index is invalidWidget.invalidateLayout()protected void applyTheme(ThemeInfo themeInfo)
Widget
applyTheme in class WidgetthemeInfo - The theme info for this widgetprotected void goKeyboard(int dir)
protected boolean isSearchChar(char ch)
protected void keyboardFocusGained()
Widget
keyboardFocusGained in class WidgetWidget.keyboardFocusGained(de.matthiasmann.twl.FocusGainedCause, de.matthiasmann.twl.Widget)protected void keyboardFocusLost()
Widget
keyboardFocusLost in class Widgetpublic boolean handleEvent(Event evt)
WidgetThe default implementation handles only keyboard events and delegates
them to the child widget which has keyboard focus.
If focusKey handling is enabled then this widget cycles the keyboard
focus through it's children.
If the key was not consumed by a child or focusKey and an inputMap is
specified then the event is translated by the InputMap and
handleKeyStrokeAction is called when a mapping was found.
If the widget wants to receive mouse events then it must return true for all mouse events except for MOUSE_WHEEL (which is optional) event. Otherwise the following mouse event are not send. Before mouse movement or button events are send a MOUSE_ENTERED event is send first.
handleEvent in class Widgetevt - The event - do not store this object - it may be reused
Widget.setFocusKeyEnabled(boolean),
Widget.handleKeyStrokeAction(java.lang.String, de.matthiasmann.twl.Event),
Widget.setInputMap(de.matthiasmann.twl.InputMap)public int getMinWidth()
Widget
getMinWidth in class Widgetpublic int getMinHeight()
Widget
getMinHeight in class Widgetpublic int getPreferredInnerWidth()
Widget
getPreferredInnerWidth in class Widgetpublic int getPreferredInnerHeight()
Widget
getPreferredInnerHeight in class Widgetprotected void paint(GUI gui)
WidgetA subclass should overwrite paintWidget() instead of this function.
The default implementation calls the following method in order:
Widget.paintBackground(de.matthiasmann.twl.GUI)Widget.paintWidget(de.matthiasmann.twl.GUI)Widget.paintChildren(de.matthiasmann.twl.GUI)Widget.paintOverlay(de.matthiasmann.twl.GUI)
paint in class Widgetgui - the GUI objectprotected void layout()
Widget
layout in class Widgetprotected ListBoxDisplay createDisplay()
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||