FileDocCategorySizeDatePackage
SynthPopupMenuUI.javaAPI DocJava SE 5 API5173Fri Aug 26 14:58:12 BST 2005javax.swing.plaf.synth

SynthPopupMenuUI

public class SynthPopupMenuUI extends BasicPopupMenuUI implements sun.swing.plaf.synth.SynthUI, PropertyChangeListener
Synth's PopupMenuUI.
version
1.21, 12/19/03
author
Georges Saab
author
David Karlton
author
Arnaud Weber

Fields Summary
private int
maxTextWidth
Maximum size of the text portion of the children menu items.
private int
maxAcceleratorWidth
Maximum size of the text for the acclerator portion of the children menu items.
private SynthStyle
style
Constructors Summary
Methods Summary
intadjustAcceleratorWidth(int width)
Adjusts the width needed to display the maximum accelerator.

param
width Text width.
return
max width

        maxAcceleratorWidth = Math.max(maxAcceleratorWidth, width);
        return maxAcceleratorWidth;
    
intadjustTextWidth(int width)
Adjusts the width needed to display the maximum menu item string.

param
width Text width.
return
max width

        maxTextWidth = Math.max(maxTextWidth, width);
        return maxTextWidth;
    
public static javax.swing.plaf.ComponentUIcreateUI(javax.swing.JComponent x)

	return new SynthPopupMenuUI();
    
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);
    
intgetMaxAcceleratorWidth()
Maximum size needed to display accelerators of children menu items.

        return maxAcceleratorWidth;
    
intgetMaxTextWidth()
Maximum size to display text of children menu items.

        return maxTextWidth;
    
private javax.swing.plaf.synth.RegiongetRegion(javax.swing.JComponent c)

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

	if (popupMenu.getLayout() == null ||
	    popupMenu.getLayout() instanceof UIResource) {
	    popupMenu.setLayout(new DefaultMenuLayout(
                                    popupMenu, BoxLayout.Y_AXIS));
        }
        updateStyle(popupMenu);
    
protected voidinstallListeners()

        super.installListeners();
        popupMenu.addPropertyChangeListener(this);
    
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)

    
public voidpaintBorder(javax.swing.plaf.synth.SynthContext context, java.awt.Graphics g, int x, int y, int w, int h)

        context.getPainter().paintPopupMenuBorder(context, g, x, y, w, h);
    
public voidpropertyChange(java.beans.PropertyChangeEvent e)

        if (SynthLookAndFeel.shouldUpdateStyle(e)) {
            updateStyle(popupMenu);
        }
    
voidresetAcceleratorWidths()
Resets the max text and accerator widths.

        maxTextWidth = maxAcceleratorWidth = 0;
    
protected voiduninstallDefaults()

        SynthContext context = getContext(popupMenu, ENABLED);

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

        if (popupMenu.getLayout() instanceof UIResource) {
            popupMenu.setLayout(null);
        }
    
protected voiduninstallListeners()

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

        SynthContext context = getContext(c);

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

        SynthContext context = getContext(c, ENABLED);
        SynthStyle oldStyle = style;
        style = SynthLookAndFeel.updateStyle(context, this);
        if (style != oldStyle) {
            if (oldStyle != null) {
                uninstallKeyboardActions();
                installKeyboardActions();
            }
        }
        context.dispose();