Class JXComboBox

    • Constructor Detail

      • JXComboBox

        public JXComboBox()
        Creates a JXComboBox 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
      • JXComboBox

        public JXComboBox​(ComboBoxModel model)
        Creates a JXComboBox 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
      • JXComboBox

        public JXComboBox​(Object[] items)
        Creates a JXComboBox 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
      • JXComboBox

        public JXComboBox​(Vector<?> items)
        Creates a JXComboBox that contains the elements in the specified Vector. By default the first item in the vector (and therefore the data model) becomes selected.
        Parameters:
        items - an array of vectors to insert into the combo box
        See Also:
        DefaultComboBoxModel
    • Method Detail

      • getPopupListFor

        protected static JList getPopupListFor​(JComboBox comboBox)
      • getComponentAdapter

        protected ComponentAdapter getComponentAdapter()
        Returns:
        the unconfigured ComponentAdapter.
      • getComponentAdapter

        protected ComponentAdapter getComponentAdapter​(int index)
        Convenience to access a configured ComponentAdapter. Note: the column index of the configured adapter is always 0.
        Parameters:
        index - the row index in view coordinates, must be valid.
        Returns:
        the configured ComponentAdapter.
      • createDefaultCellRenderer

        protected ListCellRenderer createDefaultCellRenderer()
        Creates and returns the default cell renderer to use. Subclasses may override to use a different type. Here: returns a DefaultListRenderer.
        Returns:
        the default cell renderer to use with this list.
      • getWrappedRenderer

        public ListCellRenderer getWrappedRenderer()
        Returns the renderer installed by client code or the default if none has been set.
        Returns:
        the wrapped renderer.
        See Also:
        #setCellRenderer(TreeCellRenderer)
      • setRenderer

        public void setRenderer​(ListCellRenderer renderer)

        Overridden to wrap the given renderer in a DelegatingRenderer to support highlighting.

        Note: the wrapping implies that the renderer returned from the getCellRenderer is not the renderer as given here, but the wrapper. To access the original, use getWrappedCellRenderer.

        Overrides:
        setRenderer in class JComboBox
        See Also:
        #getWrappedCellRenderer(), #getCellRenderer()
      • isUseHighlightersForCurrentValue

        public boolean isUseHighlightersForCurrentValue()
      • setUseHighlightersForCurrentValue

        public void setUseHighlightersForCurrentValue​(boolean useHighlightersForCurrentValue)
      • getHighlighters

        public Highlighter[] getHighlighters()
        Returns the Highlighters used by this column. Maybe empty, but guarantees to be never null.
        Returns:
        the Highlighters used by this column, guaranteed to never null.
        See Also:
        setHighlighters(Highlighter[])
      • getHighlighterChangeListener

        protected ChangeListener getHighlighterChangeListener()
        Returns the ChangeListener to use with highlighters. Lazily creates the listener.
        Returns:
        the ChangeListener for observing changes of highlighters, guaranteed to be not-null
      • createHighlighterChangeListener

        protected ChangeListener createHighlighterChangeListener()
        Creates and returns the ChangeListener observing Highlighters.

        A property change event is create for a state change.

        Returns:
        the ChangeListener defining the reaction to changes of highlighters.
      • updateUI

        public void updateUI()

        Overridden to update renderer and highlighters.

        Overrides:
        updateUI in class JComboBox