FileDocCategorySizeDatePackage
BasicMenuBarUI.javaAPI DocJava SE 5 API5912Fri Aug 26 14:58:04 BST 2005javax.swing.plaf.basic

BasicMenuBarUI

public class BasicMenuBarUI extends MenuBarUI
A default L&F implementation of MenuBarUI. This implementation is a "combined" view/controller.
version
1.80 12/19/03
author
Georges Saab
author
David Karlton
author
Arnaud Weber

Fields Summary
protected JMenuBar
menuBar
protected ContainerListener
containerListener
protected ChangeListener
changeListener
private Handler
handler
Constructors Summary
Methods Summary
protected javax.swing.event.ChangeListenercreateChangeListener()

        return getHandler();
    
protected java.awt.event.ContainerListenercreateContainerListener()

	return getHandler();
    
public static javax.swing.plaf.ComponentUIcreateUI(javax.swing.JComponent x)


         
	return new BasicMenuBarUI();
    
private javax.swing.plaf.basic.BasicMenuBarUI$HandlergetHandler()

        if (handler == null) {
            handler = new Handler();
        }
        return handler;
    
javax.swing.InputMapgetInputMap(int condition)

	if (condition == JComponent.WHEN_IN_FOCUSED_WINDOW) {
	    Object[] bindings = (Object[])DefaultLookup.get
		                (menuBar, this, "MenuBar.windowBindings");
	    if (bindings != null) {
		return LookAndFeel.makeComponentInputMap(menuBar, bindings);
	    }
	}
	return null;
    
public java.awt.DimensiongetMaximumSize(javax.swing.JComponent c)

        return null;
    
public java.awt.DimensiongetMinimumSize(javax.swing.JComponent c)

        return null;
    
protected voidinstallDefaults()

	if (menuBar.getLayout() == null ||
	    menuBar.getLayout() instanceof UIResource) {
            menuBar.setLayout(new DefaultMenuLayout(menuBar,BoxLayout.LINE_AXIS));
        }
  
	LookAndFeel.installProperty(menuBar, "opaque", Boolean.TRUE);
	LookAndFeel.installBorder(menuBar,"MenuBar.border");
	LookAndFeel.installColorsAndFont(menuBar,
					      "MenuBar.background",
					      "MenuBar.foreground",
					      "MenuBar.font");
    
protected voidinstallKeyboardActions()

	InputMap inputMap = getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);

	SwingUtilities.replaceUIInputMap(menuBar,
			   JComponent.WHEN_IN_FOCUSED_WINDOW, inputMap);

        LazyActionMap.installLazyActionMap(menuBar, BasicMenuBarUI.class,
                                           "MenuBar.actionMap");
    
protected voidinstallListeners()

        containerListener = createContainerListener();
        changeListener = createChangeListener();
	
        for (int i = 0; i < menuBar.getMenuCount(); i++) {
            JMenu menu = menuBar.getMenu(i);
	    if (menu!=null)
		menu.getModel().addChangeListener(changeListener);        
	}
	menuBar.addContainerListener(containerListener);
    
public voidinstallUI(javax.swing.JComponent c)

	menuBar = (JMenuBar) c;

	installDefaults();
        installListeners();
        installKeyboardActions();

    
static voidloadActionMap(javax.swing.plaf.basic.LazyActionMap map)

        map.put(new Actions(Actions.TAKE_FOCUS));
    
protected voiduninstallDefaults()

	if (menuBar!=null) {
	    LookAndFeel.uninstallBorder(menuBar);
	}
    
protected voiduninstallKeyboardActions()

	SwingUtilities.replaceUIInputMap(menuBar, JComponent.
				       WHEN_IN_FOCUSED_WINDOW, null);
	SwingUtilities.replaceUIActionMap(menuBar, null);
    
protected voiduninstallListeners()

	menuBar.removeContainerListener(containerListener);

        for (int i = 0; i < menuBar.getMenuCount(); i++) {
	    JMenu menu = menuBar.getMenu(i);
	    if (menu !=null)
		menu.getModel().removeChangeListener(changeListener);
        }

	containerListener = null;
	changeListener = null;
        handler = null;
    
public voiduninstallUI(javax.swing.JComponent c)

        uninstallDefaults();
        uninstallListeners();
        uninstallKeyboardActions();

	menuBar = null;