Package org.dwcj.controls.combobox
Class ComboBox
java.lang.Object
org.dwcj.controls.AbstractControl
org.dwcj.controls.AbstractDwcControl
org.dwcj.controls.listbox.AbstractDwclistControl
org.dwcj.controls.combobox.ComboBox
- All Implemented Interfaces:
Control,Enableable,Focusable,HasAttribute,HasClassName,HasComputedStyle,HasControlText,HasDestroy,HasReadOnly,HasStyle,HasTooltip,HasVisibility,TabTraversable,TextAlignable
public final class ComboBox
extends AbstractDwclistControl
implements HasReadOnly, Focusable, TabTraversable, TextAlignable
Combobox Control
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface org.dwcj.interfaces.TextAlignable
TextAlignable.Alignment -
Field Summary
Fields inherited from class org.dwcj.controls.listbox.AbstractDwclistControl
data2, valuesFields inherited from class org.dwcj.controls.AbstractDwcControl
BASISNUMBER_1, BASISNUMBER_25, BASISNUMBER_250, focusable, horizontalScrollBarPosition, mouseWheelCondition, readOnly, STR_EXPANSE, STR_THEME, tabTraversable, textAlignment, textHighlight, verticalScrollBarPositionFields inherited from class org.dwcj.controls.AbstractControl
ctrl, destroyed, elementId, userData -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddClassName(String selector) Adds a CSS class to the list of CSS classes for the control.Add an item into the comboboxAdds a map of items to the already-existing items within the ComboBoxprotected voidcatchUp()The catchUp method is used to replay attributes and settings that the API user might have added to a control before its creation.close()closes the ComboBox dropdown listprotected voidCreate the object on a panel p.deselect()Deselects any selected items within the ComboBoxReturns all of the values in the ComboBox as a MapReturns a single string at the given key within the boxSelects the item at the given index (0 based)Returns number of items within the ComboBoxReturns the index (0 based) of the selected item within the ComboBoxreturns the currently selected item, implemented for one-to-one value mapsReturns a value indicating the text's horizontal alignment.insertItemAt(Object key, String item, Integer index) Allows user to insert an item at a specific index within the comboBoxinsertItemsAt(Map<Object, String> items, Integer index) Inserts a map of items into the ComboBox at the desired indexisFocusable returns a value indicating whether or not the user can focus the control.Returns a value indicating whether or not a control is set to read only or not.Returns a boolean indicating whether or not the user can navigate to the control using the tab key.onClose(Consumer<ComboBoxCloseEvent> callback) Sets the behavior to be executed when the ComboBox control is closedonOpen(Consumer<ComboBoxOpenEvent> callback) Sets the behavior to be executed when the ComboBox control is openedonSelect(Consumer<ComboBoxSelectEvent> callback) Register a callback for selecting an item within the boxopen()opens the ComboBox dropdown listprotected voidpopulate()Removed all of the items within a ComboBoxremoveClassName(String selector) Removes a CSS class from the list of CSS classes for the control.removeItemAt(Integer index) Removed an item at the given index (0 based) within the ComboBoxselectIndex(Integer index) Selects the item at the given index within the ComboBoxsetAttribute(String attribute, String value) set the value for an attribute in the controlsetEnabled(Boolean enabled) Set whether the control is to be enabledsetExpanse(ComboBox.Expanse expanse) setFocusable(Boolean focusable) setFocusable sets whether a control can be focused.Assigns the ID of a controlset the list of items into the comboBoxSets the maximum number of rows allowed within the ComboBoxsetReadOnly(Boolean readOnly) Sets whether a user can edit the control.Assigns specified value to the specified CSS propertysetTabTraversable(Boolean traversable) Sets whether or not the user can navigate to the control using the tab key.set the text of the control Each control implementing this interface has a text property, which might be visible in different ways (caption, title, contents of edit) or sometimes not visible at allsetTextAlignment(TextAlignable.Alignment textAlignment) Sets the horizontal alignment of the text within the control.Sets the text at one of the specific items at the given index within the ComboBoxsetTooltipText(String text) Set the tooltip text of the controlsetVisible(Boolean visible) Set whether the control is visible or invisibleMethods inherited from class org.dwcj.controls.AbstractDwcControl
destroy, getAttribute, getComputedStyle, getText, getTooltipText, isEnabled, isVisible, setControlExpanse, setControlThemeMethods inherited from class org.dwcj.controls.AbstractControl
getCaughtUp, getId, getUserData, isDestroyed, setUserData
-
Constructor Details
-
ComboBox
public ComboBox()
-
-
Method Details
-
create
Description copied from class:AbstractControlCreate the object on a panel p. The preferred way of creating an object is using the Panel::add(Control) method, instead of this- Overrides:
createin classAbstractControl- Parameters:
p- the panel to add this control on
-
addItem
Add an item into the combobox- Parameters:
key- the item keyitem- the item's value- Returns:
- the control itself
-
insertItemAt
Allows user to insert an item at a specific index within the comboBox- Parameters:
key- Key for the item to be inserteditem- Value for the inserted itemindex- Desired index (0 based) for the inserted item- Returns:
- ComboBox object itself
-
addItems
Adds a map of items to the already-existing items within the ComboBox- Parameters:
items- Map of items to be added- Returns:
- The object itself
-
insertItemsAt
Inserts a map of items into the ComboBox at the desired index- Parameters:
items- Map of items to be addedindex- Integer representing the desired- Returns:
-
populate
protected void populate()- Specified by:
populatein classAbstractDwclistControl
-
setItems
set the list of items into the comboBox- Parameters:
values- A Map object containing the key-value pairs for the list- Returns:
- the control itself
-
deselect
Deselects any selected items within the ComboBox- Returns:
- The object itself
-
getAllItems
Returns all of the values in the ComboBox as a Map- Returns:
- all values in the comboBox
-
getItem
Returns a single string at the given key within the box- Parameters:
key- - Returns a single string at the given key within the box- Returns:
- String
-
getItemAt
Selects the item at the given index (0 based)- Parameters:
idx- Index of the desired item- Returns:
- String value of the selected item
-
getSelectedIndex
Returns the index (0 based) of the selected item within the ComboBox- Returns:
- Integer representing the selected index
-
getSelectedItem
returns the currently selected item, implemented for one-to-one value maps- Returns:
- selected entry
-
getItemCount
Returns number of items within the ComboBox- Returns:
- Integer representing the total number of items
-
open
opens the ComboBox dropdown list- Returns:
- ComboBox - returns this
-
close
closes the ComboBox dropdown list- Returns:
- ComboBox - returns this
-
onSelect
Register a callback for selecting an item within the box- Parameters:
callback- A method to receive the selection event- Returns:
- the control itself
-
onOpen
Sets the behavior to be executed when the ComboBox control is opened- Parameters:
callback- A function with the behavior desired on opening a ComboBox- Returns:
- The object itself
-
onClose
Sets the behavior to be executed when the ComboBox control is closed- Parameters:
callback- A function with the behavior desired on closing a ComboBox- Returns:
- The object itself
-
removeAllItems
Removed all of the items within a ComboBox- Returns:
- The object itself
-
removeItemAt
Removed an item at the given index (0 based) within the ComboBox- Parameters:
index- Integer for the desired index of the item to be removed- Returns:
- The object itself
-
selectIndex
Selects the item at the given index within the ComboBox- Parameters:
index- Integer representing the index of the desired item for selection- Returns:
- The object itself
-
setMaximumRowCount
Sets the maximum number of rows allowed within the ComboBox- Parameters:
max- Integer representing the desired maximum number of rows- Returns:
- The object itself
-
setTextAt
Sets the text at one of the specific items at the given index within the ComboBox- Parameters:
idx- Index of the desired item to have text settext- Desired text to be displayed at given index- Returns:
- The object itself
-
isReadOnly
Description copied from interface:HasReadOnlyReturns a value indicating whether or not a control is set to read only or not.- Specified by:
isReadOnlyin interfaceHasReadOnly- Returns:
- Boolean indicating whether or not the user can edit the control.
-
setReadOnly
Description copied from interface:HasReadOnlySets whether a user can edit the control.- Specified by:
setReadOnlyin interfaceHasReadOnly- Parameters:
readOnly- True to disable editing, false to enable editing.- Returns:
- The control itself.
-
isFocusable
Description copied from interface:FocusableisFocusable returns a value indicating whether or not the user can focus the control. Note: A focused control is the control to which keyboard interaction is directed. Typically, the focused control is indicated visually, often via a dotted grey border. A control which is not focusable, therefore, cannot be manipulated via the keyboard. It is still possible to interact with a non-focusable control via the mouse.- Specified by:
isFocusablein interfaceFocusable- Returns:
- True if object can be focused, False if not.
-
setFocusable
Description copied from interface:FocusablesetFocusable sets whether a control can be focused. Note: A focused control is the control to which keyboard interaction is directed. Typically, the focused control is indicated visually, often via a dotted grey border. A control which is not focusable, therefore, cannot be manipulated via the keyboard. It is still possible to interact with a non-focusable control via the mouse. To disable all interaction, including the mouse, see setEnabled() and setReadOnly().- Specified by:
setFocusablein interfaceFocusable- Parameters:
focusable- Boolean True for allowing focusing, False to disable focus- Returns:
- Object itself
-
isTabTraversable
Description copied from interface:TabTraversableReturns a boolean indicating whether or not the user can navigate to the control using the tab key.- Specified by:
isTabTraversablein interfaceTabTraversable- Returns:
- True if user can navigate to control with Tab key, False if not
-
setTabTraversable
Description copied from interface:TabTraversableSets whether or not the user can navigate to the control using the tab key.- Specified by:
setTabTraversablein interfaceTabTraversable- Parameters:
traversable- Boolean dictating tab traversal. True if control can be navigated to with Tab, False if not.- Returns:
- The control itself
-
getTextAlignment
Description copied from interface:TextAlignableReturns a value indicating the text's horizontal alignment.- Specified by:
getTextAlignmentin interfaceTextAlignable- Returns:
-
setTextAlignment
Description copied from interface:TextAlignableSets the horizontal alignment of the text within the control.- Specified by:
setTextAlignmentin interfaceTextAlignable- Parameters:
textAlignment- Enum from list representing an internal BBj numeric constant- Returns:
- The control itself
-
setText
Description copied from interface:HasControlTextset the text of the control Each control implementing this interface has a text property, which might be visible in different ways (caption, title, contents of edit) or sometimes not visible at all- Specified by:
setTextin interfaceHasControlText- Overrides:
setTextin classAbstractDwcControl- Returns:
- the control itself
-
setVisible
Description copied from interface:HasVisibilitySet whether the control is visible or invisible- Specified by:
setVisiblein interfaceHasVisibility- Overrides:
setVisiblein classAbstractDwcControl- Returns:
- the control itself
-
setEnabled
Description copied from interface:EnableableSet whether the control is to be enabled- Specified by:
setEnabledin interfaceEnableable- Overrides:
setEnabledin classAbstractDwcControl- Returns:
- the control itself
-
setTooltipText
Description copied from interface:HasTooltipSet the tooltip text of the control- Specified by:
setTooltipTextin interfaceHasTooltip- Overrides:
setTooltipTextin classAbstractDwcControl- Returns:
- the control itself
-
setAttribute
Description copied from class:AbstractDwcControlset the value for an attribute in the control- Specified by:
setAttributein interfaceHasAttribute- Overrides:
setAttributein classAbstractDwcControl- Parameters:
attribute- the name of the attributevalue- the value to be set- Returns:
- the control itself
-
setId
Description copied from interface:ControlAssigns the ID of a control- Specified by:
setIdin interfaceControl- Overrides:
setIdin classAbstractControl- Parameters:
elementId- Desired ID designation- Returns:
- The control itself
-
setStyle
Description copied from interface:HasStyleAssigns specified value to the specified CSS property- Specified by:
setStylein interfaceHasStyle- Overrides:
setStylein classAbstractDwcControl- Parameters:
property- The CSS property to be changedvalue- The value of the selected CSS property- Returns:
- The control itself
-
addClassName
Description copied from interface:HasClassNameAdds a CSS class to the list of CSS classes for the control.- Specified by:
addClassNamein interfaceHasClassName- Overrides:
addClassNamein classAbstractDwcControl- Returns:
- The control itself
-
removeClassName
Description copied from interface:HasClassNameRemoves a CSS class from the list of CSS classes for the control.- Specified by:
removeClassNamein interfaceHasClassName- Overrides:
removeClassNamein classAbstractDwcControl- Returns:
- The control itself
-
setExpanse
-
catchUp
Description copied from class:AbstractDwcControlThe catchUp method is used to replay attributes and settings that the API user might have added to a control before its creation. A control is not created before it's added to a panel. Anything that is added between instantiation of a control and its addition to a panel has to be recorded and replayed in this method- Overrides:
catchUpin classAbstractDwcControl- Throws:
IllegalAccessException- - thrown if an attempt is made to call this method more than once
-