FileDocCategorySizeDatePackage
BasicComboBoxRenderer.javaAPI DocJava SE 5 API3706Fri Aug 26 14:58:02 BST 2005javax.swing.plaf.basic

BasicComboBoxRenderer

public class BasicComboBoxRenderer extends JLabel implements Serializable, ListCellRenderer
ComboBox renderer

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. As of 1.4, support for long term storage of all JavaBeansTM has been added to the java.beans package. Please see {@link java.beans.XMLEncoder}.

version
1.20 12/19/03
author
Arnaud Weber

Fields Summary
protected static Border
noFocusBorder
Constructors Summary
public BasicComboBoxRenderer()


      
        super();
        setOpaque(true);
        setBorder(noFocusBorder);
    
Methods Summary
public java.awt.ComponentgetListCellRendererComponent(javax.swing.JList list, java.lang.Object value, int index, boolean isSelected, boolean cellHasFocus)


        /**if (isSelected) {
            setBackground(UIManager.getColor("ComboBox.selectionBackground"));
            setForeground(UIManager.getColor("ComboBox.selectionForeground"));
        } else {
            setBackground(UIManager.getColor("ComboBox.background"));
            setForeground(UIManager.getColor("ComboBox.foreground"));
        }**/

        if (isSelected) {
            setBackground(list.getSelectionBackground());
            setForeground(list.getSelectionForeground());
        }
        else {
            setBackground(list.getBackground());
            setForeground(list.getForeground());
        }

        setFont(list.getFont());

        if (value instanceof Icon) {
            setIcon((Icon)value);
        }
        else {
            setText((value == null) ? "" : value.toString());
        }
        return this;
    
public java.awt.DimensiongetPreferredSize()

        Dimension size;
        
        if ((this.getText() == null) || (this.getText().equals( "" ))) {
            setText( " " );
            size = super.getPreferredSize();
            setText( "" );
        }
        else {
            size = super.getPreferredSize();
        }
        
        return size;