Class BaseComboBox<E>

    • Constructor Detail

      • BaseComboBox

        public BaseComboBox()
        Creates a BaseComboBox with a default data model. The default data model is an empty list of objects. Use addItem to add items. By default the first item in the data model becomes selected.
        See Also:
        DefaultComboBoxModel
      • BaseComboBox

        public BaseComboBox​(ComboBoxModel<E> model)
        Creates a BaseComboBox that takes its items from an existing ComboBoxModel. Since the ComboBoxModel is provided, a combo box created using this constructor does not create a default combo box model and may impact how the insert, remove and add methods behave.
        Parameters:
        model - the ComboBoxModel that provides the displayed list of items
        See Also:
        DefaultComboBoxModel
      • BaseComboBox

        public BaseComboBox​(E[] items)
        Creates a BaseComboBox that contains the elements in the specified array. By default the first item in the array (and therefore the data model) becomes selected.
        Parameters:
        items - an array of objects to insert into the combo box
        See Also:
        DefaultComboBoxModel
      • BaseComboBox

        public BaseComboBox​(List<E> items)
        Creates a BaseComboBox that contains the elements in the specified list. By default the first item in the list (and therefore the data model) becomes selected.
        Parameters:
        items - list items to insert into the combo box
        See Also:
        DefaultComboBoxModel
    • Method Detail

      • initComboBox

        protected void initComboBox()
        Initializes members.
      • getSelectedItem

        public E getSelectedItem()
        Returns the current selected item.

        If the combo box is editable, then this value may not have been added to the combo box with addItem, insertItemAt or the data constructors.

        Overrides:
        getSelectedItem in class JComboBox<E>
        Returns:
        the current selected Object
      • getSelectedObjects

        public E[] getSelectedObjects()
        Returns an array containing the selected items. This method is implemented for compatibility with ItemSelectable.
        Specified by:
        getSelectedObjects in interface ItemSelectable
        Overrides:
        getSelectedObjects in class JComboBox<E>
        Returns:
        an array of Objects containing one element -- the selected item