Class 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
  • Constructor Details

    • ComboBox

      public ComboBox()
  • Method Details

    • create

      protected void create(AbstractDwcjPanel p)
      Description copied from class: AbstractControl
      Create the object on a panel p. The preferred way of creating an object is using the Panel::add(Control) method, instead of this
      Overrides:
      create in class AbstractControl
      Parameters:
      p - the panel to add this control on
    • addItem

      public ComboBox addItem(Object key, String item)
      Add an item into the combobox
      Parameters:
      key - the item key
      item - the item's value
      Returns:
      the control itself
    • insertItemAt

      public ComboBox insertItemAt(Object key, String item, Integer index)
      Allows user to insert an item at a specific index within the comboBox
      Parameters:
      key - Key for the item to be inserted
      item - Value for the inserted item
      index - Desired index (0 based) for the inserted item
      Returns:
      ComboBox object itself
    • addItems

      public ComboBox addItems(Map<Object,String> items)
      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

      public ComboBox insertItemsAt(Map<Object,String> items, Integer index)
      Inserts a map of items into the ComboBox at the desired index
      Parameters:
      items - Map of items to be added
      index - Integer representing the desired
      Returns:
    • populate

      protected void populate()
      Specified by:
      populate in class AbstractDwclistControl
    • setItems

      public ComboBox setItems(Map<Object,String> values)
      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

      public ComboBox deselect()
      Deselects any selected items within the ComboBox
      Returns:
      The object itself
    • getAllItems

      public Map<Object,String> getAllItems()
      Returns all of the values in the ComboBox as a Map
      Returns:
      all values in the comboBox
    • getItem

      public String getItem(Object key)
      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

      public String getItemAt(Integer idx)
      Selects the item at the given index (0 based)
      Parameters:
      idx - Index of the desired item
      Returns:
      String value of the selected item
    • getSelectedIndex

      public Integer getSelectedIndex()
      Returns the index (0 based) of the selected item within the ComboBox
      Returns:
      Integer representing the selected index
    • getSelectedItem

      public AbstractMap.SimpleEntry<Object,String> getSelectedItem()
      returns the currently selected item, implemented for one-to-one value maps
      Returns:
      selected entry
    • getItemCount

      public Integer getItemCount()
      Returns number of items within the ComboBox
      Returns:
      Integer representing the total number of items
    • open

      public ComboBox open()
      opens the ComboBox dropdown list
      Returns:
      ComboBox - returns this
    • close

      public ComboBox close()
      closes the ComboBox dropdown list
      Returns:
      ComboBox - returns this
    • onSelect

      public ComboBox onSelect(Consumer<ComboBoxSelectEvent> callback)
      Register a callback for selecting an item within the box
      Parameters:
      callback - A method to receive the selection event
      Returns:
      the control itself
    • onOpen

      public ComboBox onOpen(Consumer<ComboBoxOpenEvent> callback)
      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

      public ComboBox onClose(Consumer<ComboBoxCloseEvent> callback)
      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

      public ComboBox removeAllItems()
      Removed all of the items within a ComboBox
      Returns:
      The object itself
    • removeItemAt

      public ComboBox removeItemAt(Integer index)
      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

      public ComboBox selectIndex(Integer index)
      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

      public ComboBox setMaximumRowCount(Integer max)
      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

      public ComboBox setTextAt(Integer idx, String text)
      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 set
      text - Desired text to be displayed at given index
      Returns:
      The object itself
    • isReadOnly

      public Boolean isReadOnly()
      Description copied from interface: HasReadOnly
      Returns a value indicating whether or not a control is set to read only or not.
      Specified by:
      isReadOnly in interface HasReadOnly
      Returns:
      Boolean indicating whether or not the user can edit the control.
    • setReadOnly

      public ComboBox setReadOnly(Boolean readOnly)
      Description copied from interface: HasReadOnly
      Sets whether a user can edit the control.
      Specified by:
      setReadOnly in interface HasReadOnly
      Parameters:
      readOnly - True to disable editing, false to enable editing.
      Returns:
      The control itself.
    • isFocusable

      public Boolean isFocusable()
      Description copied from interface: Focusable
      isFocusable 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:
      isFocusable in interface Focusable
      Returns:
      True if object can be focused, False if not.
    • setFocusable

      public ComboBox setFocusable(Boolean focusable)
      Description copied from interface: Focusable
      setFocusable 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:
      setFocusable in interface Focusable
      Parameters:
      focusable - Boolean True for allowing focusing, False to disable focus
      Returns:
      Object itself
    • isTabTraversable

      public Boolean isTabTraversable()
      Description copied from interface: TabTraversable
      Returns a boolean indicating whether or not the user can navigate to the control using the tab key.
      Specified by:
      isTabTraversable in interface TabTraversable
      Returns:
      True if user can navigate to control with Tab key, False if not
    • setTabTraversable

      public ComboBox setTabTraversable(Boolean traversable)
      Description copied from interface: TabTraversable
      Sets whether or not the user can navigate to the control using the tab key.
      Specified by:
      setTabTraversable in interface TabTraversable
      Parameters:
      traversable - Boolean dictating tab traversal. True if control can be navigated to with Tab, False if not.
      Returns:
      The control itself
    • getTextAlignment

      public TextAlignable.Alignment getTextAlignment()
      Description copied from interface: TextAlignable
      Returns a value indicating the text's horizontal alignment.
      Specified by:
      getTextAlignment in interface TextAlignable
      Returns:
    • setTextAlignment

      public ComboBox setTextAlignment(TextAlignable.Alignment textAlignment)
      Description copied from interface: TextAlignable
      Sets the horizontal alignment of the text within the control.
      Specified by:
      setTextAlignment in interface TextAlignable
      Parameters:
      textAlignment - Enum from list representing an internal BBj numeric constant
      Returns:
      The control itself
    • setText

      public ComboBox setText(String text)
      Description copied from interface: HasControlText
      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 all
      Specified by:
      setText in interface HasControlText
      Overrides:
      setText in class AbstractDwcControl
      Returns:
      the control itself
    • setVisible

      public ComboBox setVisible(Boolean visible)
      Description copied from interface: HasVisibility
      Set whether the control is visible or invisible
      Specified by:
      setVisible in interface HasVisibility
      Overrides:
      setVisible in class AbstractDwcControl
      Returns:
      the control itself
    • setEnabled

      public ComboBox setEnabled(Boolean enabled)
      Description copied from interface: Enableable
      Set whether the control is to be enabled
      Specified by:
      setEnabled in interface Enableable
      Overrides:
      setEnabled in class AbstractDwcControl
      Returns:
      the control itself
    • setTooltipText

      public ComboBox setTooltipText(String text)
      Description copied from interface: HasTooltip
      Set the tooltip text of the control
      Specified by:
      setTooltipText in interface HasTooltip
      Overrides:
      setTooltipText in class AbstractDwcControl
      Returns:
      the control itself
    • setAttribute

      public ComboBox setAttribute(String attribute, String value)
      Description copied from class: AbstractDwcControl
      set the value for an attribute in the control
      Specified by:
      setAttribute in interface HasAttribute
      Overrides:
      setAttribute in class AbstractDwcControl
      Parameters:
      attribute - the name of the attribute
      value - the value to be set
      Returns:
      the control itself
    • setId

      public ComboBox setId(String elementId)
      Description copied from interface: Control
      Assigns the ID of a control
      Specified by:
      setId in interface Control
      Overrides:
      setId in class AbstractControl
      Parameters:
      elementId - Desired ID designation
      Returns:
      The control itself
    • setStyle

      public ComboBox setStyle(String property, String value)
      Description copied from interface: HasStyle
      Assigns specified value to the specified CSS property
      Specified by:
      setStyle in interface HasStyle
      Overrides:
      setStyle in class AbstractDwcControl
      Parameters:
      property - The CSS property to be changed
      value - The value of the selected CSS property
      Returns:
      The control itself
    • addClassName

      public ComboBox addClassName(String selector)
      Description copied from interface: HasClassName
      Adds a CSS class to the list of CSS classes for the control.
      Specified by:
      addClassName in interface HasClassName
      Overrides:
      addClassName in class AbstractDwcControl
      Returns:
      The control itself
    • removeClassName

      public ComboBox removeClassName(String selector)
      Description copied from interface: HasClassName
      Removes a CSS class from the list of CSS classes for the control.
      Specified by:
      removeClassName in interface HasClassName
      Overrides:
      removeClassName in class AbstractDwcControl
      Returns:
      The control itself
    • setExpanse

      public ComboBox setExpanse(ComboBox.Expanse expanse)
    • catchUp

      protected void catchUp() throws IllegalAccessException
      Description copied from class: AbstractDwcControl
      The 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:
      catchUp in class AbstractDwcControl
      Throws:
      IllegalAccessException - - thrown if an attempt is made to call this method more than once