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

BasicDesktopPaneUI

public class BasicDesktopPaneUI extends DesktopPaneUI
Basic L&F for a desktop.
version
1.55 05/18/04
author
Steve Wilson

Fields Summary
private static final Actions
SHARED_ACTION
private static Dimension
minSize
private static Dimension
maxSize
private Handler
handler
private PropertyChangeListener
pcl
protected JDesktopPane
desktop
protected DesktopManager
desktopManager
protected KeyStroke
minimizeKey
As of Java 2 platform v1.3 this previously undocumented field is no longer used. Key bindings are now defined by the LookAndFeel, please refer to the key bindings specification for further details.
protected KeyStroke
maximizeKey
As of Java 2 platform v1.3 this previously undocumented field is no longer used. Key bindings are now defined by the LookAndFeel, please refer to the key bindings specification for further details.
protected KeyStroke
closeKey
As of Java 2 platform v1.3 this previously undocumented field is no longer used. Key bindings are now defined by the LookAndFeel, please refer to the key bindings specification for further details.
protected KeyStroke
navigateKey
As of Java 2 platform v1.3 this previously undocumented field is no longer used. Key bindings are now defined by the LookAndFeel, please refer to the key bindings specification for further details.
protected KeyStroke
navigateKey2
As of Java 2 platform v1.3 this previously undocumented field is no longer used. Key bindings are now defined by the LookAndFeel, please refer to the key bindings specification for further details.
private static Vector
framesCache
Constructors Summary
public BasicDesktopPaneUI()

    
Methods Summary
javax.swing.InputMapcreateInputMap(int condition)

	if (condition == JComponent.WHEN_IN_FOCUSED_WINDOW) {
	    Object[] bindings = (Object[])DefaultLookup.get(desktop,
                    this, "Desktop.windowBindings");

	    if (bindings != null) {
		return LookAndFeel.makeComponentInputMap(desktop, bindings);
	    }
	}
	return null;
    
protected java.beans.PropertyChangeListenercreatePropertyChangeListener()
Returns the PropertyChangeListener to install on the JDesktopPane.

since
1.5
return
The PropertyChangeListener that will be added to track changes in the desktop pane.

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


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

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

	if (condition == JComponent.WHEN_IN_FOCUSED_WINDOW) {
	    return createInputMap(condition);
	}
	else if (condition == JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT) {
	    return (InputMap)DefaultLookup.get(desktop, this,
                    "Desktop.ancestorInputMap");
	}
	return null;
    
public java.awt.DimensiongetMaximumSize(javax.swing.JComponent c)

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

	return minSize;
	
public java.awt.DimensiongetPreferredSize(javax.swing.JComponent c)

return null;
protected voidinstallDefaults()

	if (desktop.getBackground() == null || 
	    desktop.getBackground() instanceof UIResource) {
	    desktop.setBackground(UIManager.getColor("Desktop.background"));
	}
        LookAndFeel.installProperty(desktop, "opaque", Boolean.TRUE);
    
protected voidinstallDesktopManager()

        desktopManager = desktop.getDesktopManager();
	if(desktopManager == null) {
	    desktopManager = new BasicDesktopManager();
	    desktop.setDesktopManager(desktopManager);
	}
    
protected voidinstallKeyboardActions()

	InputMap inputMap = getInputMap(JComponent.WHEN_IN_FOCUSED_WINDOW);
	if (inputMap != null) {
	    SwingUtilities.replaceUIInputMap(desktop,
			JComponent.WHEN_IN_FOCUSED_WINDOW, inputMap);
	}
	inputMap = getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT);
	if (inputMap != null) {
	    SwingUtilities.replaceUIInputMap(desktop,
			JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT,
			inputMap);
	}

        LazyActionMap.installLazyActionMap(desktop, BasicDesktopPaneUI.class,
                "DesktopPane.actionMap");
	registerKeyboardActions();
    
protected voidinstallListeners()
Installs the PropertyChangeListener returned from createPropertyChangeListener on the JDesktopPane.

since
1.5
see
#createPropertyChangeListener

        pcl = createPropertyChangeListener();
        desktop.addPropertyChangeListener(pcl);
    
public voidinstallUI(javax.swing.JComponent c)

	desktop = (JDesktopPane)c;
	installDefaults();
	installDesktopManager();
        installListeners();
	installKeyboardActions();
    
static voidloadActionMap(javax.swing.plaf.basic.LazyActionMap map)

        map.put(new Actions(Actions.RESTORE));
        map.put(new Actions(Actions.CLOSE));
        map.put(new Actions(Actions.MOVE));
        map.put(new Actions(Actions.RESIZE));
        map.put(new Actions(Actions.LEFT));
        map.put(new Actions(Actions.SHRINK_LEFT));
        map.put(new Actions(Actions.RIGHT));
        map.put(new Actions(Actions.SHRINK_RIGHT));
        map.put(new Actions(Actions.UP));
        map.put(new Actions(Actions.SHRINK_UP));
        map.put(new Actions(Actions.DOWN));
        map.put(new Actions(Actions.SHRINK_DOWN));
        map.put(new Actions(Actions.ESCAPE));
        map.put(new Actions(Actions.MINIMIZE));
        map.put(new Actions(Actions.MAXIMIZE));
        map.put(new Actions(Actions.NEXT_FRAME));
        map.put(new Actions(Actions.PREVIOUS_FRAME));
        map.put(new Actions(Actions.NAVIGATE_NEXT));
        map.put(new Actions(Actions.NAVIGATE_PREVIOUS));
    
public voidpaint(java.awt.Graphics g, javax.swing.JComponent c)

protected voidregisterKeyboardActions()

    
protected voiduninstallDefaults()

 
protected voiduninstallDesktopManager()

	if(desktop.getDesktopManager() instanceof UIResource) {
	    desktop.setDesktopManager(null);
	}
	desktopManager = null;
    
protected voiduninstallKeyboardActions()

 
      unregisterKeyboardActions();
      SwingUtilities.replaceUIInputMap(desktop, JComponent.
				     WHEN_IN_FOCUSED_WINDOW, null);
      SwingUtilities.replaceUIInputMap(desktop, JComponent.
				     WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, null);
      SwingUtilities.replaceUIActionMap(desktop, null);
    
protected voiduninstallListeners()
Uninstalls the PropertyChangeListener returned from createPropertyChangeListener from the JDesktopPane.

since
1.5
see
#createPropertyChangeListener

        desktop.removePropertyChangeListener(pcl);
        pcl = null;
    
public voiduninstallUI(javax.swing.JComponent c)

	uninstallKeyboardActions();
        uninstallListeners();
	uninstallDesktopManager();
        uninstallDefaults();
	desktop = null;
        handler = null;
    
protected voidunregisterKeyboardActions()

    
private static voidverifyFramesCache(javax.swing.JDesktopPane dp)

	if (framesCache == null) {
	    framesCache = new Vector();
	}

	// Check whether any internal frames have closed in
	// which case we have to refresh the frames cache.
       	boolean framesHaveClosed = false;
	int len = framesCache.size();
	for (int i = 0; i < len; i++) {
	    JComponent c = 
		(JComponent)framesCache.elementAt(i);
	    if (c instanceof JInternalFrame) {
		JInternalFrame f = (JInternalFrame)c;
		if (f.isClosed()) {
		    framesHaveClosed = true;
		    break;
		}
	    }
	    else if (c instanceof JInternalFrame.JDesktopIcon) {
		JInternalFrame.JDesktopIcon icon = 
		    (JInternalFrame.JDesktopIcon)c;
		JInternalFrame f = (JInternalFrame)icon.getInternalFrame();
		if (f.isClosed()) {
		    framesHaveClosed = true;
		    break;
		}
	    }
	} 
       	JInternalFrame [] allFrames = dp.getAllFrames();
       	if (framesHaveClosed || allFrames.length != framesCache.size()) {
	    // Cache frames starting at the lowest layer.
	    framesCache.clear();
	    int low = dp.lowestLayer();
	    int high = dp.highestLayer();
	    for (int i = high; i >= low; i--) {
		Component [] comp = dp.getComponentsInLayer(i);
		if (comp.length > 0) {
		    for (int j = 0; j < comp.length; j++) {
			framesCache.addElement(comp[j]);
		    }
		}
	    }
       	}