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

SynthPopupMenuUI

public class SynthPopupMenuUI extends BasicPopupMenuUI implements sun.swing.plaf.synth.SynthUI, PropertyChangeListener
Synth's PopupMenuUI.
version
1.23, 11/17/05
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 int
maxTextOffset
private int
maxIconOffset
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;
    
intadjustIconOffset(int offset)
Adjusts the icon offset needed to align icons horizontally

param
offset Icon offset
return
max offset

        maxIconOffset = Math.max(maxIconOffset, offset);
        return maxIconOffset;
    
intadjustTextOffset(int offset)
Adjusts the text offset needed to align text horizontally.

param
offset Text offset
return
max offset

        maxTextOffset = Math.max(maxTextOffset, offset);
        return maxTextOffset;
    
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);
        }
    
voidresetAlignmentHints()
Resets the max text and accerator widths, text and icon offsets.

        maxTextWidth = maxAcceleratorWidth
                     = maxTextOffset = maxIconOffset = 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();