FileDocCategorySizeDatePackage
BasicComboBoxUI.javaAPI DocJava SE 6 API64753Tue Jun 10 00:26:46 BST 2008javax.swing.plaf.basic

BasicComboBoxUI

public class BasicComboBoxUI extends ComboBoxUI
Basic UI implementation for JComboBox.

The combo box is a compound component which means that it is an agregate of many simpler components. This class creates and manages the listeners on the combo box and the combo box model. These listeners update the user interface in response to changes in the properties and state of the combo box.

All event handling is handled by listener classes created with the createxxxListener() methods and internal classes. You can change the behavior of this class by overriding the createxxxListener() methods and supplying your own event listeners or subclassing from the ones supplied in this class.

For adding specific actions, overide installKeyboardActions to add actions in response to KeyStroke bindings. See the article Keyboard Bindings in Swing at The Swing Connection.

version
1.187 06/22/07
author
Arnaud Weber
author
Tom Santos
author
Mark Davidson

Fields Summary
protected JComboBox
comboBox
protected boolean
hasFocus
This protected field is implementation specific. Do not access directly or override.
private boolean
isTableCellEditor
private static final String
IS_TABLE_CELL_EDITOR
protected JList
listBox
protected CellRendererPane
currentValuePane
protected ComboPopup
popup
protected Component
editor
protected JButton
arrowButton
protected KeyListener
keyListener
This protected field is implementation specific. Do not access directly or override. Override the listener construction method instead.
protected FocusListener
focusListener
This protected field is implementation specific. Do not access directly or override. Override the listener construction method instead.
protected PropertyChangeListener
propertyChangeListener
This protected field is implementation specific. Do not access directly or override. Override the listener construction method instead.
protected ItemListener
itemListener
This protected field is implementation specific. Do not access directly or override. Override the listener construction method instead.
protected MouseListener
popupMouseListener
protected MouseMotionListener
popupMouseMotionListener
protected KeyListener
popupKeyListener
protected ListDataListener
listDataListener
This protected field is implementation specific. Do not access directly or override. Override the listener construction method instead.
private Handler
handler
Implements all the Listeners needed by this class, all existing listeners redirect to it.
private long
timeFactor
The time factor to treate the series of typed alphanumeric key as prefix for first letter navigation.
private long
lastTime
This is tricky, this variables is needed for DefaultKeySelectionManager to take into account time factor.
private long
time
JComboBox$KeySelectionManager
keySelectionManager
The default key selection manager
protected boolean
isMinimumSizeDirty
protected Dimension
cachedMinimumSize
private boolean
isDisplaySizeDirty
private Dimension
cachedDisplaySize
private static final Object
COMBO_UI_LIST_CELL_RENDERER_KEY
static final StringBuffer
HIDE_POPUP_KEY
private boolean
sameBaseline
Whether or not all cells have the same baseline.
Constructors Summary
Methods Summary
public voidaddEditor()
This public method is implementation specific and should be private. do not call or override. To implement a specific editor create a custom ComboBoxEditor

see
#createEditor
see
javax.swing.JComboBox#setEditor
see
javax.swing.ComboBoxEditor

        removeEditor();
        editor = comboBox.getEditor().getEditorComponent();
        if ( editor != null ) {
            configureEditor(); 
            comboBox.add(editor);
            if(comboBox.isFocusOwner()) {
                // Switch focus to the editor component
                editor.requestFocusInWindow();
            }
        }
    
public voidconfigureArrowButton()
This public method is implementation specific and should be private. Do not call or override.

see
#createArrowButton

        if ( arrowButton != null ) {
            arrowButton.setEnabled( comboBox.isEnabled() );
            arrowButton.setFocusable(comboBox.isFocusable());
            arrowButton.setRequestFocusEnabled(false);
	    arrowButton.addMouseListener( popup.getMouseListener() );
	    arrowButton.addMouseMotionListener( popup.getMouseMotionListener() );
            arrowButton.resetKeyboardActions();
            arrowButton.putClientProperty("doNotCancelPopup", HIDE_POPUP_KEY);
            arrowButton.setInheritsPopupMenu(true);
        }
    
protected voidconfigureEditor()
This protected method is implementation specific and should be private. do not call or override.

see
#addEditor

        // Should be in the same state as the combobox
        editor.setEnabled(comboBox.isEnabled());

        editor.setFocusable(comboBox.isFocusable());

        editor.setFont( comboBox.getFont() );

        if (focusListener != null) {
            editor.addFocusListener(focusListener);
        }

	editor.addFocusListener( getHandler() );

	comboBox.getEditor().addActionListener(getHandler());

        if(editor instanceof JComponent) {
            ((JComponent)editor).putClientProperty("doNotCancelPopup",
                                                   HIDE_POPUP_KEY);
            ((JComponent)editor).setInheritsPopupMenu(true);
        }

        comboBox.configureEditor(comboBox.getEditor(),comboBox.getSelectedItem());
    
protected javax.swing.JButtoncreateArrowButton()
Creates an button which will be used as the control to show or hide the popup portion of the combo box.

return
a button which represents the popup control

        JButton button = new BasicArrowButton(BasicArrowButton.SOUTH,
				    UIManager.getColor("ComboBox.buttonBackground"),
				    UIManager.getColor("ComboBox.buttonShadow"),
				    UIManager.getColor("ComboBox.buttonDarkShadow"),
				    UIManager.getColor("ComboBox.buttonHighlight"));
        button.setName("ComboBox.arrowButton");
        return button;
    
protected javax.swing.ComboBoxEditorcreateEditor()
Creates the default editor that will be used in editable combo boxes. A default editor will be used only if an editor has not been explicitly set with setEditor.

return
a ComboBoxEditor used for the combo box
see
javax.swing.JComboBox#setEditor

        return new BasicComboBoxEditor.UIResource();
    
protected java.awt.event.FocusListenercreateFocusListener()
Creates a FocusListener which will be added to the combo box. If this method returns null then it will not be added to the combo box.

return
an instance of a FocusListener or null

        return getHandler();
    
protected java.awt.event.ItemListenercreateItemListener()
Creates an ItemListener which will be added to the combo box. If this method returns null then it will not be added to the combo box.

Subclasses may override this method to return instances of their own ItemEvent handlers.

return
an instance of an ItemListener or null

        return null;
    
protected java.awt.event.KeyListenercreateKeyListener()
Creates a KeyListener which will be added to the combo box. If this method returns null then it will not be added to the combo box.

return
an instance KeyListener or null

        return getHandler();
    
protected java.awt.LayoutManagercreateLayoutManager()
Creates a layout manager for managing the components which make up the combo box.

return
an instance of a layout manager

        return getHandler();
    
protected javax.swing.event.ListDataListenercreateListDataListener()
Creates a list data listener which will be added to the ComboBoxModel. If this method returns null then it will not be added to the combo box model.

return
an instance of a ListDataListener or null

        return getHandler();
    
protected javax.swing.plaf.basic.ComboPopupcreatePopup()
Creates the popup portion of the combo box.

return
an instance of ComboPopup
see
ComboPopup

        return new BasicComboPopup( comboBox );
    
protected java.beans.PropertyChangeListenercreatePropertyChangeListener()
Creates a PropertyChangeListener which will be added to the combo box. If this method returns null then it will not be added to the combo box.

return
an instance of a PropertyChangeListener or null

        return getHandler();
    
protected javax.swing.ListCellRenderercreateRenderer()
Creates the default renderer that will be used in a non-editiable combo box. A default renderer will used only if a renderer has not been explicitly set with setRenderer.

return
a ListCellRender used for the combo box
see
javax.swing.JComboBox#setRenderer

        return new BasicComboBoxRenderer.UIResource();
    
public static javax.swing.plaf.ComponentUIcreateUI(javax.swing.JComponent c)

        return new BasicComboBoxUI();
    
public javax.accessibility.AccessiblegetAccessibleChild(javax.swing.JComponent c, int i)

        // 0 = the popup
        // 1 = the editor
        switch ( i ) {
        case 0:
            if ( popup instanceof Accessible ) {
                AccessibleContext ac = ((Accessible) popup).getAccessibleContext();
                ac.setAccessibleParent(comboBox);
                return(Accessible) popup;
            }
            break;
        case 1:
            if ( comboBox.isEditable() 
                 && (editor instanceof Accessible) ) {
                AccessibleContext ac = ((Accessible) editor).getAccessibleContext();
                ac.setAccessibleParent(comboBox);
                return(Accessible) editor;
            }
            break;
        }
        return null;
    
public intgetAccessibleChildrenCount(javax.swing.JComponent c)

        if ( comboBox.isEditable() ) {
            return 2;
        }
        else {
            return 1;
        }
    
public intgetBaseline(javax.swing.JComponent c, int width, int height)
Returns the baseline.

throws
NullPointerException {@inheritDoc}
throws
IllegalArgumentException {@inheritDoc}
see
javax.swing.JComponent#getBaseline(int, int)
since
1.6

        super.getBaseline(c, width, height);
        int baseline = -1;
        // force sameBaseline to be updated.
        getDisplaySize();
        if (sameBaseline) {
            Insets insets = c.getInsets();
            height = height - insets.top - insets.bottom;
            if (!comboBox.isEditable()) {
                ListCellRenderer renderer = comboBox.getRenderer();
                if (renderer == null)  {
                    renderer = new DefaultListCellRenderer();
                }
                Object value = null;
                Object prototypeValue = comboBox.getPrototypeDisplayValue();
                if (prototypeValue != null)  {
                    value = prototypeValue;
                }
                else if (comboBox.getModel().getSize() > 0) {
                    // Note, we're assuming the baseline is the same for all
                    // cells, if not, this needs to loop through all.
                    value = comboBox.getModel().getElementAt(0);
                }
                if (value == null) {
                    value = " ";
                } else if (value instanceof String && "".equals(value)) {
                    value = " ";
                }
                Component component = renderer.
                        getListCellRendererComponent(listBox, value, -1,
                                                     false, false);
                if (component instanceof JComponent) {
                    component.setFont(comboBox.getFont());
                }
                baseline = component.getBaseline(width, height);
            }
            else {
                baseline = editor.getBaseline(width, height);
            }
            if (baseline > 0) {
                baseline += insets.top;
            }
        }
        return baseline;
    
public java.awt.Component$BaselineResizeBehaviorgetBaselineResizeBehavior(javax.swing.JComponent c)
Returns an enum indicating how the baseline of the component changes as the size changes.

throws
NullPointerException {@inheritDoc}
see
javax.swing.JComponent#getBaseline(int, int)
since
1.6

        super.getBaselineResizeBehavior(c);
        // Force sameBaseline to be updated.
        getDisplaySize();
        if (comboBox.isEditable()) {
            return editor.getBaselineResizeBehavior();
        }
        else if (sameBaseline) {
            ListCellRenderer renderer = comboBox.getRenderer();
            if (renderer == null)  {
                renderer = new DefaultListCellRenderer();
            }
            Object value = null;
            Object prototypeValue = comboBox.getPrototypeDisplayValue();
            if (prototypeValue != null)  {
                value = prototypeValue;
            }
            else if (comboBox.getModel().getSize() > 0) {
                // Note, we're assuming the baseline is the same for all
                // cells, if not, this needs to loop through all.
                value = comboBox.getModel().getElementAt(0);
            }
            if (value != null) {
                Component component = renderer.
                        getListCellRendererComponent(listBox, value, -1,
                                                     false, false);
                return component.getBaselineResizeBehavior();
            }
        }
        return Component.BaselineResizeBehavior.OTHER;
    
private static javax.swing.ListCellRenderergetDefaultListCellRenderer()


    // Used for calculating the default size.
        
        ListCellRenderer renderer = (ListCellRenderer)AppContext.
                         getAppContext().get(COMBO_UI_LIST_CELL_RENDERER_KEY);

        if (renderer == null) {
            renderer = new DefaultListCellRenderer();
            AppContext.getAppContext().put(COMBO_UI_LIST_CELL_RENDERER_KEY,
                                           new DefaultListCellRenderer());
        }
        return renderer;
    
protected java.awt.DimensiongetDefaultSize()
Return the default size of an empty display area of the combo box using the current renderer and font.

return
the size of an empty display area
see
#getDisplaySize

	// Calculates the height and width using the default text renderer
	Dimension d = getSizeForComponent(getDefaultListCellRenderer().getListCellRendererComponent(listBox, " ", -1, false, false));

        return new Dimension(d.width, d.height);
    
protected java.awt.DimensiongetDisplaySize()
Returns the calculated size of the display area. The display area is the portion of the combo box in which the selected item is displayed. This method will use the prototype display value if it has been set.

For combo boxes with a non trivial number of items, it is recommended to use a prototype display value to significantly speed up the display size calculation.

return
the size of the display area calculated from the combo box items
see
javax.swing.JComboBox#setPrototypeDisplayValue

        if (!isDisplaySizeDirty)  {
            return new Dimension(cachedDisplaySize);
        }
	Dimension result = new Dimension();
        
        ListCellRenderer renderer = comboBox.getRenderer();
        if (renderer == null)  {
            renderer = new DefaultListCellRenderer();
        }

        sameBaseline = true;

        Object prototypeValue = comboBox.getPrototypeDisplayValue();
        if (prototypeValue != null)  {
            // Calculates the dimension based on the prototype value
            result = getSizeForComponent(renderer.getListCellRendererComponent(listBox, 
									       prototypeValue,
									       -1, false, false));
        } else {
            // Calculate the dimension by iterating over all the elements in the combo
            // box list.
            ComboBoxModel model = comboBox.getModel();
            int modelSize = model.getSize();
            int baseline = -1;
	    Dimension d;

            Component cpn;
            
            if (modelSize > 0 ) {
                for (int i = 0; i < modelSize ; i++ ) {
                    // Calculates the maximum height and width based on the largest
                    // element
                    Object value = model.getElementAt(i);
                    Component c = renderer.getListCellRendererComponent(
                            listBox, value, -1, false, false);
                    d = getSizeForComponent(c);
                    if (sameBaseline && value != null &&
                            (!(value instanceof String) || !"".equals(value))) {
                        int newBaseline = c.getBaseline(d.width, d.height);
                        if (newBaseline == -1) {
                            sameBaseline = false;
                        }
                        else if (baseline == -1) {
                            baseline = newBaseline;
                        }
                        else if (baseline != newBaseline) {
                            sameBaseline = false;
                        }
                    }
                    result.width = Math.max(result.width,d.width);
                    result.height = Math.max(result.height,d.height);
                }
            } else {
		result = getDefaultSize();
		if (comboBox.isEditable()) {
		    result.width = 100;
		}
            }
        }

	if ( comboBox.isEditable() ) {
	    Dimension d = editor.getPreferredSize();
	    result.width = Math.max(result.width,d.width);
	    result.height = Math.max(result.height,d.height);
	}
        
        // Set the cached value
        cachedDisplaySize.setSize(result.width, result.height);
        isDisplaySizeDirty = false;

        return result;
    
private javax.swing.plaf.basic.BasicComboBoxUI$HandlergetHandler()
Returns the shared listener.

        if (handler == null) {
            handler = new Handler();
        }
        return handler;
    
javax.swing.InputMapgetInputMap(int condition)

	if (condition == JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) {
	    return (InputMap)DefaultLookup.get(comboBox, this,
                                               "ComboBox.ancestorInputMap");
	}
	return null;
    
protected java.awt.InsetsgetInsets()
Gets the insets from the JComboBox.

        return comboBox.getInsets();
    
public java.awt.DimensiongetMaximumSize(javax.swing.JComponent c)

	return new Dimension(Short.MAX_VALUE, Short.MAX_VALUE);
    
public java.awt.DimensiongetMinimumSize(javax.swing.JComponent c)
The minumum size is the size of the display area plus insets plus the button.

        if ( !isMinimumSizeDirty ) {
            return new Dimension(cachedMinimumSize);
        }
        Dimension size = getDisplaySize();
        Insets insets = getInsets();
        size.height += insets.top + insets.bottom;
        int buttonSize = size.height - (insets.top + insets.bottom);
        size.width +=  insets.left + insets.right + buttonSize;

        cachedMinimumSize.setSize( size.width, size.height ); 
        isMinimumSizeDirty = false;

        return new Dimension(size);
    
public java.awt.DimensiongetPreferredSize(javax.swing.JComponent c)

	return getMinimumSize(c);
    
private java.awt.DimensiongetSizeForComponent(java.awt.Component comp)
This has been refactored out in hopes that it may be investigated and simplified for the next major release. adding/removing the component to the currentValuePane and changing the font may be redundant operations.

	currentValuePane.add(comp);
	comp.setFont(comboBox.getFont());
	Dimension d = comp.getPreferredSize();
	currentValuePane.remove(comp);
	return d;
    
protected voidinstallComponents()
Creates and initializes the components which make up the aggregate combo box. This method is called as part of the UI installation process.

        arrowButton = createArrowButton();
        comboBox.add( arrowButton );

        if (arrowButton != null)  {
            configureArrowButton();
        }

        if ( comboBox.isEditable() ) {
            addEditor();
        }

        comboBox.add( currentValuePane );
    
protected voidinstallDefaults()
Installs the default colors, default font, default renderer, and default editor into the JComboBox.

        LookAndFeel.installColorsAndFont( comboBox,
                                          "ComboBox.background",
                                          "ComboBox.foreground",
                                          "ComboBox.font" );
        LookAndFeel.installBorder( comboBox, "ComboBox.border" );
        LookAndFeel.installProperty( comboBox, "opaque", Boolean.TRUE);

 	Long l = (Long)UIManager.get("ComboBox.timeFactor");
 	timeFactor = (l!=null) ? l.longValue() : 1000L;
    
protected voidinstallKeyboardActions()
Adds keyboard actions to the JComboBox. Actions on enter and esc are already supplied. Add more actions as you need them.

	InputMap km = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
	SwingUtilities.replaceUIInputMap(comboBox, JComponent.
			     WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, km);


        LazyActionMap.installLazyActionMap(comboBox, BasicComboBoxUI.class,
                                           "ComboBox.actionMap");
    
protected voidinstallListeners()
Create and install the listeners for the combo box and its model. This method is called when the UI is installed.

	if ( (itemListener = createItemListener()) != null) {
	    comboBox.addItemListener( itemListener );
	}
        if ( (propertyChangeListener = createPropertyChangeListener()) != null ) {
            comboBox.addPropertyChangeListener( propertyChangeListener );
        }
        if ( (keyListener = createKeyListener()) != null ) {
            comboBox.addKeyListener( keyListener );
        }
        if ( (focusListener = createFocusListener()) != null ) {
            comboBox.addFocusListener( focusListener );
        }
	if ((popupMouseListener = popup.getMouseListener()) != null) {
	    comboBox.addMouseListener( popupMouseListener );
	}
	if ((popupMouseMotionListener = popup.getMouseMotionListener()) != null) {
	    comboBox.addMouseMotionListener( popupMouseMotionListener );
	}
	if ((popupKeyListener = popup.getKeyListener()) != null) {
	    comboBox.addKeyListener(popupKeyListener);
	}

        if ( comboBox.getModel() != null ) {
            if ( (listDataListener = createListDataListener()) != null ) {
                comboBox.getModel().addListDataListener( listDataListener );
            }
        }
    
public voidinstallUI(javax.swing.JComponent c)

        isMinimumSizeDirty = true;

        comboBox = (JComboBox)c;
        installDefaults();
        popup = createPopup();
        listBox = popup.getList();

	// Is this combo box a cell editor?
        Boolean inTable = (Boolean)c.getClientProperty(IS_TABLE_CELL_EDITOR );
	if (inTable != null) {
	    isTableCellEditor = inTable.equals(Boolean.TRUE) ? true : false;
	}

        if ( comboBox.getRenderer() == null || comboBox.getRenderer() instanceof UIResource ) {
            comboBox.setRenderer( createRenderer() );
        }

        if ( comboBox.getEditor() == null || comboBox.getEditor() instanceof UIResource ) {
            comboBox.setEditor( createEditor() );
        }

        installListeners();
        installComponents();

        comboBox.setLayout( createLayoutManager() );

        comboBox.setRequestFocusEnabled( true );

	installKeyboardActions();

        comboBox.putClientProperty("doNotCancelPopup", HIDE_POPUP_KEY);

        if (keySelectionManager == null || keySelectionManager instanceof UIResource) {
            keySelectionManager = new DefaultKeySelectionManager();
	}
	comboBox.setKeySelectionManager(keySelectionManager);
    
public booleanisFocusTraversable(javax.swing.JComboBox c)
Determines if the JComboBox is focus traversable. If the JComboBox is editable this returns false, otherwise it returns true.

        return !comboBox.isEditable();
    
protected booleanisNavigationKey(int keyCode)
Returns whether or not the supplied keyCode maps to a key that is used for navigation. This is used for optimizing key input by only passing non- navigation keys to the type-ahead mechanism. Subclasses should override this if they change the navigation keys.

        return keyCode == KeyEvent.VK_UP || keyCode == KeyEvent.VK_DOWN ||
               keyCode == KeyEvent.VK_KP_UP || keyCode == KeyEvent.VK_KP_DOWN;
    
private booleanisNavigationKey(int keyCode, int modifiers)

 	InputMap inputMap = comboBox.getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
 	KeyStroke key = KeyStroke.getKeyStroke(keyCode, modifiers);
	
 	if (inputMap != null && inputMap.get(key) != null) {
 	    return true;
 	}
 	return false;
    
public booleanisPopupVisible(javax.swing.JComboBox c)
Tells if the popup is visible or not.

        return popup.isVisible();
    
booleanisTableCellEditor()

	return isTableCellEditor;
    
static voidloadActionMap(javax.swing.plaf.basic.LazyActionMap map)
Populates ComboBox's actions.

	map.put(new Actions(Actions.HIDE));
	map.put(new Actions(Actions.PAGE_DOWN));
	map.put(new Actions(Actions.PAGE_UP));
	map.put(new Actions(Actions.HOME));
	map.put(new Actions(Actions.END));
	map.put(new Actions(Actions.DOWN));
	map.put(new Actions(Actions.DOWN_2));
	map.put(new Actions(Actions.TOGGLE));
	map.put(new Actions(Actions.TOGGLE_2));
	map.put(new Actions(Actions.UP));
	map.put(new Actions(Actions.UP_2));
	map.put(new Actions(Actions.ENTER));
    
public voidpaint(java.awt.Graphics g, javax.swing.JComponent c)

        hasFocus = comboBox.hasFocus();
        if ( !comboBox.isEditable() ) {
            Rectangle r = rectangleForCurrentValue();
            paintCurrentValueBackground(g,r,hasFocus);
            paintCurrentValue(g,r,hasFocus);
        }
    
public voidpaintCurrentValue(java.awt.Graphics g, java.awt.Rectangle bounds, boolean hasFocus)
Paints the currently selected item.

        ListCellRenderer renderer = comboBox.getRenderer();
        Component c;

        if ( hasFocus && !isPopupVisible(comboBox) ) {
            c = renderer.getListCellRendererComponent( listBox,
                                                       comboBox.getSelectedItem(),
                                                       -1,
                                                       true,
                                                       false );
        }
        else {
            c = renderer.getListCellRendererComponent( listBox,
                                                       comboBox.getSelectedItem(),
                                                       -1,
                                                       false,
                                                       false );
            c.setBackground(UIManager.getColor("ComboBox.background"));
        }
        c.setFont(comboBox.getFont());
        if ( hasFocus && !isPopupVisible(comboBox) ) {
            c.setForeground(listBox.getSelectionForeground());
            c.setBackground(listBox.getSelectionBackground());
        }
        else {
            if ( comboBox.isEnabled() ) {
                c.setForeground(comboBox.getForeground());
                c.setBackground(comboBox.getBackground());
            }
            else {
                c.setForeground(DefaultLookup.getColor(
                         comboBox, this, "ComboBox.disabledForeground", null));
                c.setBackground(DefaultLookup.getColor(
                         comboBox, this, "ComboBox.disabledBackground", null));
            }
        }

        // Fix for 4238829: should lay out the JPanel.
        boolean shouldValidate = false;
        if (c instanceof JPanel)  {
            shouldValidate = true;
        }

        currentValuePane.paintComponent(g,c,comboBox,bounds.x,bounds.y,
                                        bounds.width,bounds.height, shouldValidate);
    
public voidpaintCurrentValueBackground(java.awt.Graphics g, java.awt.Rectangle bounds, boolean hasFocus)
Paints the background of the currently selected item.

        Color t = g.getColor();
        if ( comboBox.isEnabled() )
            g.setColor(DefaultLookup.getColor(comboBox, this,
                                              "ComboBox.background", null));
        else
            g.setColor(DefaultLookup.getColor(comboBox, this,
                                     "ComboBox.disabledBackground", null));
        g.fillRect(bounds.x,bounds.y,bounds.width,bounds.height);
        g.setColor(t);
    
protected java.awt.RectanglerectangleForCurrentValue()
Returns the area that is reserved for drawing the currently selected item.

        int width = comboBox.getWidth();
        int height = comboBox.getHeight();
        Insets insets = getInsets();
        int buttonSize = height - (insets.top + insets.bottom);
	if ( arrowButton != null ) {
            buttonSize = arrowButton.getWidth();
	}
	if(BasicGraphicsUtils.isLeftToRight(comboBox)) {
	    return new Rectangle(insets.left, insets.top,
			     width - (insets.left + insets.right + buttonSize),
                             height - (insets.top + insets.bottom));
	}
	else {
	    return new Rectangle(insets.left + buttonSize, insets.top,
			     width - (insets.left + insets.right + buttonSize),
                             height - (insets.top + insets.bottom));
	}
    
public voidremoveEditor()
This public method is implementation specific and should be private. do not call or override.

see
#addEditor

        if ( editor != null ) {
            unconfigureEditor();
            comboBox.remove( editor );
	    editor = null;
        }
    
voidrepaintCurrentValue()
Repaint the currently selected item.

        Rectangle r = rectangleForCurrentValue();
        comboBox.repaint(r.x,r.y,r.width,r.height);
    
protected voidselectNextPossibleValue()
Selects the next item in the list. It won't change the selection if the currently selected item is already the last item.

        int si;

        if ( isTableCellEditor ) {
            si = listBox.getSelectedIndex();
        }
        else {
            si = comboBox.getSelectedIndex();
        }

        if ( si < comboBox.getModel().getSize() - 1 ) {
            if ( isTableCellEditor ) {
                listBox.setSelectedIndex( si + 1 );
                listBox.ensureIndexIsVisible( si + 1 );
            }
            else {
                comboBox.setSelectedIndex(si+1);
            }
            comboBox.repaint();
        }
    
protected voidselectPreviousPossibleValue()
Selects the previous item in the list. It won't change the selection if the currently selected item is already the first item.

        int si;

        if ( isTableCellEditor ) {
            si = listBox.getSelectedIndex();
        }
        else {
            si = comboBox.getSelectedIndex();
        }

        if ( si > 0 ) {
            if ( isTableCellEditor ) {
                listBox.setSelectedIndex( si - 1 );
                listBox.ensureIndexIsVisible( si - 1 );
            }
            else {
                comboBox.setSelectedIndex(si-1);
            }

            comboBox.repaint();
        }
    
public voidsetPopupVisible(javax.swing.JComboBox c, boolean v)
Hides the popup.

        if ( v ) {
            popup.show();
        } else {
            popup.hide();
        }
    
protected voidtoggleOpenClose()
Hides the popup if it is showing and shows the popup if it is hidden.

        setPopupVisible(comboBox, !isPopupVisible(comboBox));
    
public voidunconfigureArrowButton()
This public method is implementation specific and should be private. Do not call or override.

see
#createArrowButton

        if ( arrowButton != null ) {
	    arrowButton.removeMouseListener( popup.getMouseListener() );
	    arrowButton.removeMouseMotionListener( popup.getMouseMotionListener() );
        }
    
protected voidunconfigureEditor()
This protected method is implementation specific and should be private. Do not call or override.

see
#addEditor

        if (focusListener != null) {
            editor.removeFocusListener(focusListener);
        }

        editor.removeFocusListener(getHandler());
        comboBox.getEditor().removeActionListener(getHandler());
    
protected voiduninstallComponents()
The aggregate components which compise the combo box are unregistered and uninitialized. This method is called as part of the UI uninstallation process.

        if ( arrowButton != null ) {
            unconfigureArrowButton();
        }
        if ( editor != null ) {
            unconfigureEditor();
        }
        comboBox.removeAll(); // Just to be safe.
        arrowButton = null;
    
protected voiduninstallDefaults()
Uninstalls the default colors, default font, default renderer, and default editor into the JComboBox.

        LookAndFeel.installColorsAndFont( comboBox,
                                          "ComboBox.background",
                                          "ComboBox.foreground",
                                          "ComboBox.font" );
        LookAndFeel.uninstallBorder( comboBox );
    
protected voiduninstallKeyboardActions()
Removes the focus InputMap and ActionMap.

	SwingUtilities.replaceUIInputMap(comboBox, JComponent.
				 WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, null);
	SwingUtilities.replaceUIActionMap(comboBox, null);
    
protected voiduninstallListeners()
Remove the installed listeners from the combo box and its model. The number and types of listeners removed and in this method should be the same that was added in installListeners

        if ( keyListener != null ) {
            comboBox.removeKeyListener( keyListener );
        }
	if ( itemListener != null) {
	    comboBox.removeItemListener( itemListener );
	}
        if ( propertyChangeListener != null ) {
            comboBox.removePropertyChangeListener( propertyChangeListener );
        }
        if ( focusListener != null) {
            comboBox.removeFocusListener( focusListener );
        }
	if ( popupMouseListener != null) {
	    comboBox.removeMouseListener( popupMouseListener );
	}
	if ( popupMouseMotionListener != null) {
	    comboBox.removeMouseMotionListener( popupMouseMotionListener );
	}
	if (popupKeyListener != null) {
	    comboBox.removeKeyListener(popupKeyListener);
	}
        if ( comboBox.getModel() != null ) {
            if ( listDataListener != null ) {
                comboBox.getModel().removeListDataListener( listDataListener );
            }
        }
    
public voiduninstallUI(javax.swing.JComponent c)

        setPopupVisible( comboBox, false);
        popup.uninstallingUI();

        uninstallKeyboardActions();

        comboBox.setLayout( null );

        uninstallComponents();
        uninstallListeners();
        uninstallDefaults();

        if ( comboBox.getRenderer() == null || comboBox.getRenderer() instanceof UIResource ) {
            comboBox.setRenderer( null );
        }

        ComboBoxEditor comboBoxEditor = comboBox.getEditor(); 
        if (comboBoxEditor instanceof UIResource ) { 
            if (comboBoxEditor.getEditorComponent().hasFocus()) { 
                // Leave focus in JComboBox.
                comboBox.requestFocusInWindow();
            }
            comboBox.setEditor( null );
        }

        if (keySelectionManager instanceof UIResource) {
	    comboBox.setKeySelectionManager(null);
	}

        handler = null;
        keyListener = null;
        focusListener = null;
        listDataListener = null;
        propertyChangeListener = null;
        popup = null;
        listBox = null;
        comboBox = null;
    
private voidupdateToolTipTextForChildren()

        Component[] children = comboBox.getComponents();
        for ( int i = 0; i < children.length; ++i ) {
            if ( children[i] instanceof JComponent ) {
                ((JComponent)children[i]).setToolTipText( comboBox.getToolTipText() );
            }
        }