# Class SynthComboBoxUI

java.lang.Object
javax.swing.plaf.ComponentUI
javax.swing.plaf.ComboBoxUI
javax.swing.plaf.basic.BasicComboBoxUI
javax.swing.plaf.synth.SynthComboBoxUI

All Implemented Interfaces:
  `PropertyChangeListener, EventListener, SynthConstants, SynthUI`

public class SynthComboBoxUI extends BasicComboBoxUI implements PropertyChangeListener, SynthUI
Provides the Synth L&F UI delegate for `JComboBox`.

Since:
  1.7

- ## Nested Class Summary

  ### Nested classes/interfaces declared in class BasicComboBoxUI

  `BasicComboBoxUI.ComboBoxLayoutManager, BasicComboBoxUI.FocusHandler, BasicComboBoxUI.ItemHandler, BasicComboBoxUI.KeyHandler, BasicComboBoxUI.ListDataHandler, BasicComboBoxUI.PropertyChangeHandler`
  Modifier and Type
  Class
  Description
  `class`
  `BasicComboBoxUI.ComboBoxLayoutManager`
  This layout manager handles the 'standard' layout of combo boxes.
  `class`
  `BasicComboBoxUI.FocusHandler`
  This listener hides the popup when the focus is lost.
  `class`
  `BasicComboBoxUI.ItemHandler`
  This listener watches for changes to the selection in the combo box.
  `class`
  `BasicComboBoxUI.KeyHandler`
  This listener checks to see if the key event isn't a navigation key.
  `class`
  `BasicComboBoxUI.ListDataHandler`
  This listener watches for changes in the `ComboBoxModel`.
  `class`
  `BasicComboBoxUI.PropertyChangeHandler`
  This listener watches for bound properties that have changed in the combo box.

- ## Field Summary

  ### Fields declared in class BasicComboBoxUI

  `arrowButton, cachedMinimumSize, comboBox, currentValuePane, editor, focusListener, hasFocus, isMinimumSizeDirty, itemListener, keyListener, listBox, listDataListener, padding, popup, popupKeyListener, popupMouseListener, popupMouseMotionListener, propertyChangeListener, squareButton`
  Modifier and Type
  Field
  Description
  `protected JButton`
  `arrowButton`
  The arrow button that invokes the popup.
  `protected Dimension`
  `cachedMinimumSize`
  The cached minimum preferred size.
  `protected JComboBox<Object>`
  `comboBox`
  The instance of `JComboBox`.
  `protected CellRendererPane`
  `currentValuePane`
  Used to render the currently selected item in the combo box.
  `protected Component`
  `editor`
  The Component that the `ComboBoxEditor` uses for editing.
  `protected FocusListener`
  `focusListener`
  This protected field is implementation specific.
  `protected boolean`
  `hasFocus`
  This protected field is implementation specific.
  `protected boolean`
  `isMinimumSizeDirty`
  The flag for recalculating the minimum preferred size.
  `protected ItemListener`
  `itemListener`
  This protected field is implementation specific.
  `protected KeyListener`
  `keyListener`
  This protected field is implementation specific.
  `protected JList<Object>`
  `listBox`
  This list is for drawing the current item in the combo box.
  `protected ListDataListener`
  `listDataListener`
  This protected field is implementation specific.
  `protected Insets`
  `padding`
  If specified, these insets act as padding around the cell renderer when laying out and painting the "selected" item in the combo box.
  `protected ComboPopup`
  `popup`
  The implementation of `ComboPopup` that is used to show the popup.
  `protected KeyListener`
  `popupKeyListener`
  The `KeyListener` listens to events.
  `protected MouseListener`
  `popupMouseListener`
  The `MouseListener` listens to events.
  `protected MouseMotionListener`
  `popupMouseMotionListener`
  The `MouseMotionListener` listens to events.
  `protected PropertyChangeListener`
  `propertyChangeListener`
  This protected field is implementation specific.
  `protected boolean`
  `squareButton`
  Indicates whether or not the combo box button should be square.

  ### Fields declared in interface SynthConstants

  `DEFAULT, DISABLED, ENABLED, FOCUSED, MOUSE_OVER, PRESSED, SELECTED`
  Modifier and Type
  Field
  Description
  `static final int`
  `DEFAULT`
  Indicates the region is the default.
  `static final int`
  `DISABLED`
  Primary state indicating the region is not enabled.
  `static final int`
  `ENABLED`
  Primary state indicating the component is enabled.
  `static final int`
  `FOCUSED`
  Indicates the region has focus.
  `static final int`
  `MOUSE_OVER`
  Primary state indicating the mouse is over the region.
  `static final int`
  `PRESSED`
  Primary state indicating the region is in a pressed state.
  `static final int`
  `SELECTED`
  Indicates the region is selected.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `SynthComboBoxUI()`
  Constructs a `SynthComboBoxUI`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `static ComponentUI`
  `createUI(JComponent c)`
  Creates a new UI object for the given component.
  `SynthContext`
  `getContext(JComponent c)`
  Returns the Context for the specified component.
  `protected Dimension`
  `getDefaultSize()`
  Returns the default size of an empty display area of the combo box using the current renderer and font.
  `Dimension`
  `getMinimumSize(JComponent c)`
  The minimum size is the size of the display area plus insets plus the button.
  `void`
  `installUI(JComponent c)`
  Configures the specified component appropriately for the look and feel.
  `void`
  `paint(Graphics g, JComponent c)`
  Paints the specified component according to the Look and Feel.
  `protected void`
  `paint(SynthContext context, Graphics g)`
  Paints the specified component.
  `void`
  `paintBorder(SynthContext context, Graphics g, int x, int y, int w, int h)`
  Paints the border.
  `void`
  `paintCurrentValue(Graphics g, Rectangle bounds, boolean hasFocus)`
  Paints the currently selected item.
  `void`
  `propertyChange(PropertyChangeEvent e)`
  This method gets called when a bound property is changed.
  `void`
  `update(Graphics g, JComponent c)`
  Notifies this UI delegate to repaint the specified component.

  ### Methods declared in class BasicComboBoxUI

  `addEditor, configureArrowButton, configureEditor, createArrowButton, createEditor, createFocusListener, createItemListener, createKeyListener, createLayoutManager, createListDataListener, createPopup, createPropertyChangeListener, createRenderer, getBaseline, getBaselineResizeBehavior, getDisplaySize, getInsets, getSizeForComponent, installComponents, installDefaults, installKeyboardActions, installListeners, isFocusTraversable, isNavigationKey, isPopupVisible, paintCurrentValueBackground, rectangleForCurrentValue, removeEditor, selectNextPossibleValue, selectPreviousPossibleValue, setPopupVisible, toggleOpenClose, unconfigureArrowButton, unconfigureEditor, uninstallComponents, uninstallDefaults, uninstallKeyboardActions, uninstallListeners`
  Modifier and Type
  Method
  Description
  `void`
  `addEditor()`
  This public method is implementation specific and should be private. do not call or override.
  `void`
  `configureArrowButton()`
  This public method is implementation specific and should be private.
  `protected void`
  `configureEditor()`
  This protected method is implementation specific and should be private. do not call or override.
  `protected JButton`
  `createArrowButton()`
  Creates a button which will be used as the control to show or hide the popup portion of the combo box.
  `protected ComboBoxEditor`
  `createEditor()`
  Creates the default editor that will be used in editable combo boxes.
  `protected FocusListener`
  `createFocusListener()`
  Creates a `FocusListener` which will be added to the combo box.
  `protected ItemListener`
  `createItemListener()`
  Creates an `ItemListener` which will be added to the combo box.
  `protected KeyListener`
  `createKeyListener()`
  Creates a `KeyListener` which will be added to the combo box.
  `protected LayoutManager`
  `createLayoutManager()`
  Creates a layout manager for managing the components which make up the combo box.
  `protected ListDataListener`
  `createListDataListener()`
  Creates a list data listener which will be added to the `ComboBoxModel`.
  `protected ComboPopup`
  `createPopup()`
  Creates the popup portion of the combo box.
  `protected PropertyChangeListener`
  `createPropertyChangeListener()`
  Creates a `PropertyChangeListener` which will be added to the combo box.
  `protected ListCellRenderer<Object>`
  `createRenderer()`
  Creates the default renderer that will be used in a non-editiable combo box.
  `int`
  `getBaseline(JComponent c, int width, int height)`
  Returns the baseline.
  `Component.BaselineResizeBehavior`
  `getBaselineResizeBehavior(JComponent c)`
  Returns an enum indicating how the baseline of the component changes as the size changes.
  `protected Dimension`
  `getDisplaySize()`
  Returns the calculated size of the display area.
  `protected Insets`
  `getInsets()`
  Gets the insets from the JComboBox.
  `protected Dimension`
  `getSizeForComponent(Component comp)`
  Returns the size a component would have if used as a cell renderer.
  `protected void`
  `installComponents()`
  Creates and initializes the components which make up the aggregate combo box.
  `protected void`
  `installDefaults()`
  Installs the default colors, default font, default renderer, and default editor into the JComboBox.
  `protected void`
  `installKeyboardActions()`
  Adds keyboard actions to the JComboBox.
  `protected void`
  `installListeners()`
  Creates and installs listeners for the combo box and its model.
  `boolean`
  `isFocusTraversable(JComboBox<?> c)`
  Determines if the JComboBox is focus traversable.
  `protected boolean`
  `isNavigationKey(int keyCode)`
  Returns whether or not the supplied keyCode maps to a key that is used for navigation.
  `boolean`
  `isPopupVisible(JComboBox<?> c)`
  Tells if the popup is visible or not.
  `void`
  `paintCurrentValueBackground(Graphics g, Rectangle bounds, boolean hasFocus)`
  Paints the background of the currently selected item.
  `protected Rectangle`
  `rectangleForCurrentValue()`
  Returns the area that is reserved for drawing the currently selected item.
  `void`
  `removeEditor()`
  This public method is implementation specific and should be private. do not call or override.
  `protected void`
  `selectNextPossibleValue()`
  Selects the next item in the list.
  `protected void`
  `selectPreviousPossibleValue()`
  Selects the previous item in the list.
  `void`
  `setPopupVisible(JComboBox<?> c, boolean v)`
  Hides the popup.
  `protected void`
  `toggleOpenClose()`
  Hides the popup if it is showing and shows the popup if it is hidden.
  `void`
  `unconfigureArrowButton()`
  This public method is implementation specific and should be private.
  `protected void`
  `unconfigureEditor()`
  This protected method is implementation specific and should be private.
  `protected void`
  `uninstallComponents()`
  The aggregate components which comprise the combo box are unregistered and uninitialized.
  `protected void`
  `uninstallDefaults()`
  Uninstalls the default colors, default font, default renderer, and default editor from the combo box.
  `protected void`
  `uninstallKeyboardActions()`
  Removes the focus InputMap and ActionMap.
  `protected void`
  `uninstallListeners()`
  Removes the installed listeners from the combo box and its model.

  ### Methods declared in class ComponentUI

  `contains, getAccessibleChild, getAccessibleChildrenCount, getMaximumSize, getPreferredSize, uninstallUI`
  Modifier and Type
  Method
  Description
  `boolean`
  `contains(JComponent c, int x, int y)`
  Returns `true` if the specified x,y location is contained within the look and feel's defined shape of the specified component.
  `Accessible`
  `getAccessibleChild(JComponent c, int i)`
  Returns the `i`th `Accessible` child of the object.
  `int`
  `getAccessibleChildrenCount(JComponent c)`
  Returns the number of accessible children in the object.
  `Dimension`
  `getMaximumSize(JComponent c)`
  Returns the specified component's maximum size appropriate for the look and feel.
  `Dimension`
  `getPreferredSize(JComponent c)`
  Returns the specified component's preferred size appropriate for the look and feel.
  `void`
  `uninstallUI(JComponent c)`
  Reverses configuration which was done on the specified component during `installUI`.

  ### Methods declared in class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
  Modifier and Type
  Method
  Description
  `protected Object`
  `clone()`
  Creates and returns a copy of this object.
  `boolean`
  `equals(Object obj)`
  Indicates whether some other object is "equal to" this one.
  `protected void`
  `finalize()`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Finalization is deprecated and subject to removal in a future release.
  `final Class<?>`
  `getClass()`
  Returns the runtime class of this `Object`.
  `int`
  `hashCode()`
  Returns a hash code value for this object.
  `final void`
  `notify()`
  Wakes up a single thread that is waiting on this object's monitor.
  `final void`
  `notifyAll()`
  Wakes up all threads that are waiting on this object's monitor.
  `String`
  `toString()`
  Returns a string representation of the object.
  `final void`
  `wait()`
  Causes the current thread to wait until it is awakened, typically by being notified or interrupted.
  `final void`
  `wait(long timeoutMillis)`
  Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
  `final void`
  `wait(long timeoutMillis, int nanos)`
  Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

- ## Constructor Details

  - ### SynthComboBoxUI

    public SynthComboBoxUI()
    Constructs a `SynthComboBoxUI`.

- ## Method Details

  - ### createUI

    public static ComponentUI createUI(JComponent c)
    Creates a new UI object for the given component.
    Parameters:
      `c` - component to create UI object for
    Returns:
      the UI object

  - ### installUI

    public void installUI(JComponent c)
    Configures the specified component appropriately for the look and feel. This method is invoked when the `ComponentUI` instance is being installed as the UI delegate on the specified component. This method should completely configure the component for the look and feel, including the following:
    1. Install default property values for color, fonts, borders, icons, opacity, etc. on the component. Whenever possible, property values initialized by the client program should not be overridden.
    2. Install a `LayoutManager` on the component if necessary.
    3. Create/add any required sub-components to the component.
    4. Create/install event listeners on the component.
    5. Create/install a `PropertyChangeListener` on the component in order to detect and respond to component property changes appropriately.
    6. Install keyboard UI (mnemonics, traversal, etc.) on the component.
    7. Initialize any appropriate instance data.
    Overridden to ensure that ButtonHandler is created prior to any of the other installXXX methods, since several of them reference buttonHandler.
    Overrides:
      `installUI` in class `ComponentUI`
    Parameters:
      `c` - the component where this UI delegate is being installed
    See Also:
      - `ComponentUI.uninstallUI(JComponent)`
      - `JComponent.setUI(ComponentUI)`
      - `JComponent.updateUI()`

  - ### getContext

    public SynthContext getContext(JComponent c)
    Returns the Context for the specified component.
    Specified by:
      `getContext` in interface `SynthUI`
    Parameters:
      `c` - Component requesting SynthContext.
    Returns:
      SynthContext describing component.

  - ### propertyChange

    public void propertyChange(PropertyChangeEvent e)
    This method gets called when a bound property is changed.
    Specified by:
      `propertyChange` in interface `PropertyChangeListener`
    Parameters:
      `e` - A PropertyChangeEvent object describing the event source and the property that has changed.

  - ### update

    public void update(Graphics g, JComponent c)
    Notifies this UI delegate to repaint the specified component. This method paints the component background, then calls the `paint(SynthContext,Graphics)` method.

    In general, this method does not need to be overridden by subclasses. All Look and Feel rendering code should reside in the `paint` method.

    Overrides:
      `update` in class `ComponentUI`
    Parameters:
      `g` - the `Graphics` object used for painting
      `c` - the component being painted
    See Also:
      - `paint(SynthContext,Graphics)`

  - ### getMinimumSize

    public Dimension getMinimumSize(JComponent c)
    The minimum size is the size of the display area plus insets plus the button.
    Overrides:
      `getMinimumSize` in class `BasicComboBoxUI`
    Parameters:
      `c` - the component whose minimum size is being queried; this argument is often ignored, but might be used if the UI object is stateless and shared by multiple components
    Returns:
      a `Dimension` object or `null`
    See Also:
      - `JComponent.getMinimumSize()`
      - `LayoutManager.minimumLayoutSize(Container)`
      - `ComponentUI.getPreferredSize(JComponent)`

  - ### paint

    public void paint(Graphics g, JComponent c)
    Paints the specified component according to the Look and Feel.

    This method is not used by Synth Look and Feel. Painting is handled by the `paint(SynthContext,Graphics)` method.

    Overrides:
      `paint` in class `ComponentUI`
    Parameters:
      `g` - the `Graphics` object used for painting
      `c` - the component being painted
    See Also:
      - `paint(SynthContext,Graphics)`

  - ### paint

    protected void paint(SynthContext context, Graphics g)
    Paints the specified component.
    Parameters:
      `context` - context for the component being painted
      `g` - the `Graphics` object used for painting
    See Also:
      - `update(Graphics,JComponent)`

  - ### paintBorder

    public void paintBorder(SynthContext context, Graphics g, int x, int y, int w, int h)
    Paints the border.
    Specified by:
      `paintBorder` in interface `SynthUI`
    Parameters:
      `context` - a component context
      `g` - `Graphics` to paint on
      `x` - the X coordinate
      `y` - the Y coordinate
      `w` - width of the border
      `h` - height of the border

  - ### paintCurrentValue

    public void paintCurrentValue(Graphics g, Rectangle bounds, boolean hasFocus)
    Paints the currently selected item.
    Overrides:
      `paintCurrentValue` in class `BasicComboBoxUI`
    Parameters:
      `g` - an instance of `Graphics`
      `bounds` - a bounding rectangle to render to
      `hasFocus` - is focused

  - ### getDefaultSize

    protected Dimension getDefaultSize()
    Returns the default size of an empty display area of the combo box using the current renderer and font. This method was overridden to use SynthComboBoxRenderer instead of DefaultListCellRenderer as the default renderer when calculating the size of the combo box. This is used in the case of the combo not having any data.
    Overrides:
      `getDefaultSize` in class `BasicComboBoxUI`
    Returns:
      the size of an empty display area
    See Also:
      - `BasicComboBoxUI.getDisplaySize()`