Class SmartComboBox<T>

    • Constructor Detail

      • SmartComboBox

        public SmartComboBox​(ComboBoxModel aModel)
        Creates a JComboBox that takes it's 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:
        aModel - the ComboBoxModel that provides the displayed list of items
        See Also:
        DefaultComboBoxModel
      • SmartComboBox

        public SmartComboBox​(T[] items)
        Creates a JComboBox 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
      • SmartComboBox

        public SmartComboBox()
        Creates a JComboBox 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
    • Method Detail

      • setSelectedItem

        public void setSelectedItem​(Object anObject)
        Sets the selected item in the combo box display area to the object in the argument. If anObject is in the list, the display area shows anObject selected.

        If anObject is not in the list and the combo box is uneditable, it will not change the current selection. For editable combo boxes, the selection will change to anObject.

        If this constitutes a change in the selected item, ItemListeners added to the combo box will be notified with one or two ItemEvents. If there is a current selected item, an ItemEvent will be fired and the state change will be ItemEvent.DESELECTED. If anObject is in the list and is not currently selected then an ItemEvent will be fired and the state change will be ItemEvent.SELECTED.

        ActionListeners added to the combo box will be notified with an ActionEvent when this method is called.

        Overrides:
        setSelectedItem in class JComboBox
        Parameters:
        anObject - the list object to select; use null to clear the selection