FileDocCategorySizeDatePackage
SynthComboBoxUI.javaAPI DocJava SE 6 API11019Tue Jun 10 00:26:54 BST 2008javax.swing.plaf.synth

SynthComboBoxUI

public class SynthComboBoxUI extends BasicComboBoxUI implements sun.swing.plaf.synth.SynthUI, PropertyChangeListener
Synth's ComboBoxUI.
version
1.18, 03/15/07
author
Scott Violet

Fields Summary
private SynthStyle
style
private boolean
useListColors
Constructors Summary
Methods Summary
protected javax.swing.JButtoncreateArrowButton()

        SynthArrowButton button = new SynthArrowButton(SwingConstants.SOUTH);
        button.setName("ComboBox.arrowButton");
        return button;
    
protected javax.swing.ComboBoxEditorcreateEditor()

        return new SynthComboBoxEditor();
    
protected javax.swing.plaf.basic.ComboPopupcreatePopup()

        SynthComboPopup popup = new SynthComboPopup( comboBox );
        return popup;
    
protected javax.swing.ListCellRenderercreateRenderer()

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

        return new SynthComboBoxUI();
    
private intgetComponentState(javax.swing.JComponent c)

        return SynthLookAndFeel.getComponentState(c);
    
public javax.swing.plaf.synth.SynthContextgetContext(javax.swing.JComponent c)

        return getContext(c, getComponentState(c));
    
private javax.swing.plaf.synth.SynthContextgetContext(javax.swing.JComponent c, int state)

        return SynthContext.getContext(SynthContext.class, c,
                    SynthLookAndFeel.getRegion(c), style, state);
    
private javax.swing.plaf.synth.RegiongetRegion(javax.swing.JComponent c)

        return SynthLookAndFeel.getRegion(c);
    
protected voidinstallDefaults()

        updateStyle(comboBox);
    
protected voidinstallListeners()

        comboBox.addPropertyChangeListener(this);
        super.installListeners();
    
public voidpaint(java.awt.Graphics g, javax.swing.JComponent c)

        SynthContext context = getContext(c);

        paint(context, g);
        context.dispose();
    
protected voidpaint(javax.swing.plaf.synth.SynthContext context, java.awt.Graphics g)

        hasFocus = comboBox.hasFocus();
        if ( !comboBox.isEditable() ) {
            Rectangle r = rectangleForCurrentValue();
            paintCurrentValue(g,r,hasFocus);
        }
    
public voidpaintBorder(javax.swing.plaf.synth.SynthContext context, java.awt.Graphics g, int x, int y, int w, int h)

        context.getPainter().paintComboBoxBorder(context, g, x, y, w, h);
    
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,
                                                       false,
                                                       false );
        }
        else {
            c = renderer.getListCellRendererComponent( listBox,
                                                       comboBox.getSelectedItem(),
                                                       -1,
                                                       false,
                                                       false );
        }
        // Fix for 4238829: should lay out the JPanel.
        boolean shouldValidate = false;
        if (c instanceof JPanel)  {
            shouldValidate = true;
        }

        if (c instanceof UIResource) {
            c.setName("ComboBox.renderer");
            currentValuePane.paintComponent(g,c,comboBox,bounds.x,bounds.y,
                                        bounds.width,bounds.height, shouldValidate);
        }
        else {
            currentValuePane.paintComponent(g,c,comboBox,bounds.x,bounds.y,
                                        bounds.width,bounds.height, shouldValidate);
        }
    
public voidpropertyChange(java.beans.PropertyChangeEvent e)

        if (SynthLookAndFeel.shouldUpdateStyle(e)) {
            updateStyle(comboBox);
        }
    
protected voiduninstallDefaults()

        SynthContext context = getContext(comboBox, ENABLED);

        style.uninstallDefaults(context);
        context.dispose();
        style = null;
    
protected voiduninstallListeners()

        comboBox.removePropertyChangeListener(this);
        super.uninstallListeners();
    
public voidupdate(java.awt.Graphics g, javax.swing.JComponent c)

        SynthContext context = getContext(c);

        SynthLookAndFeel.update(context, g);
        context.getPainter().paintComboBoxBackground(context, g, 0, 0,
                                                  c.getWidth(), c.getHeight());
        paint(context, g);
        context.dispose();
    
private voidupdateStyle(javax.swing.JComboBox comboBox)

        SynthStyle oldStyle = style;
        SynthContext context = getContext(comboBox, ENABLED);

        style = SynthLookAndFeel.updateStyle(context, this);
        if (style != oldStyle) {
            useListColors = style.getBoolean(context,
                                  "ComboBox.rendererUseListColors", true);
            if (oldStyle != null) {
                uninstallKeyboardActions();
                installKeyboardActions();
            }
        }
        context.dispose();