FileDocCategorySizeDatePackage
WindowsComboBoxUI.javaAPI DocJava SE 5 API6268Fri Aug 26 14:54:48 BST 2005com.sun.java.swing.plaf.windows

WindowsComboBoxUI

public class WindowsComboBoxUI extends BasicComboBoxUI
Windows combo box.

Warning: Serialized objects of this class will not be compatible with future Swing releases. The current serialization support is appropriate for short term storage or RMI between applications running the same version of Swing. A future release of Swing will provide support for long term persistence.

version
1.46, 03/25/05
author
Tom Santos

Fields Summary
MouseListener
rolloverListener
Constructors Summary
Methods Summary
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

	if (XPStyle.getXP() != null) {
	    return new XPComboBoxButton();
	} else {
	    return super.createArrowButton();
	}
    
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 WindowsComboBoxEditor();
    
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 new BasicComboBoxUI.ComboBoxLayoutManager() {
	    public void layoutContainer(Container parent) {
		super.layoutContainer(parent);

		if (XPStyle.getXP() != null && arrowButton != null) {
		    Dimension d = parent.getSize();
		    Insets insets = getInsets();
		    int buttonWidth = arrowButton.getPreferredSize().width;
		    arrowButton.setBounds(WindowsUtils.isLeftToRight((JComboBox)parent)
					  ? (d.width - insets.right - buttonWidth)
					  : insets.left,
					  insets.top,
					  buttonWidth, d.height - insets.top - insets.bottom);
		}
	    }
	};
    
protected javax.swing.plaf.basic.ComboPopupcreatePopup()

        return super.createPopup();
    
public static javax.swing.plaf.ComponentUIcreateUI(javax.swing.JComponent c)

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

        Dimension d = super.getPreferredSize(c);
        d.width += 4;
        d.height += 2;
        if (XPStyle.getXP() != null) {
            d.height += 2;
        }
        return d;
    
protected voidinstallKeyboardActions()

        super.installKeyboardActions();
    
public voidinstallUI(javax.swing.JComponent c)

        super.installUI( c );
        comboBox.setRequestFocusEnabled( true );
        if (XPStyle.getXP() != null  && arrowButton != null) {
            rolloverListener = new RolloverListener();
            comboBox.addMouseListener(rolloverListener);
        }
    
public voidpaintCurrentValue(java.awt.Graphics g, java.awt.Rectangle bounds, boolean hasFocus)
If necessary paints the currently selected item.

param
g Graphics to paint to
param
bounds Region to paint current value to
param
hasFocus whether or not the JComboBox has focus
throws
NullPointerException if any of the arguments are null.
since
1.5

	if (XPStyle.getXP() != null) {
	    bounds.x += 2;
	    bounds.y += 2;
	    bounds.width -= 3;
	    bounds.height -= 4;
	} else {
	    bounds.x += 1;
	    bounds.y += 1;
	    bounds.width -= 2;
	    bounds.height -= 2;
	}
	super.paintCurrentValue(g, bounds, hasFocus);
    
public voiduninstallUI(javax.swing.JComponent c)

        if (XPStyle.getXP() != null) {
            comboBox.removeMouseListener(rolloverListener);
        }
        super.uninstallUI( c );