KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > java > swing > plaf > windows > WindowsDesktopManager


1 /*
2  * @(#)WindowsDesktopManager.java 1.18 03/12/19
3  *
4  * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
5  * SUN PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
6  */

7
8
9 package com.sun.java.swing.plaf.windows;
10
11 import javax.swing.DefaultDesktopManager JavaDoc;
12 import javax.swing.JInternalFrame JavaDoc;
13 import javax.swing.JLayeredPane JavaDoc;
14 import java.awt.Component JavaDoc;
15 import java.awt.Container JavaDoc;
16 import java.awt.Dimension JavaDoc;
17 import java.beans.PropertyVetoException JavaDoc;
18 import java.util.Vector JavaDoc;
19
20 /**
21  * This class implements a DesktopManager which more closely follows
22  * the MDI model than the DefaultDesktopManager. Unlike the
23  * DefaultDesktopManager policy, MDI requires that the selected
24  * and activated child frames are the same, and that that frame
25  * always be the top-most window.
26  * <p>
27  * The maximized state is managed by the DesktopManager with MDI,
28  * instead of just being a property of the individual child frame.
29  * This means that if the currently selected window is maximized
30  * and another window is selected, that new window will be maximized.
31  *
32  * @see javax.swing.DefaultDesktopManager
33  * @version 1.18 12/19/03
34  * @author Thomas Ball
35  */

36 public class WindowsDesktopManager extends DefaultDesktopManager JavaDoc
37         implements java.io.Serializable JavaDoc, javax.swing.plaf.UIResource JavaDoc {
38
39     /* The frame which is currently selected/activated.
40      * We store this value to enforce MDI's single-selection model.
41      */

42     JInternalFrame JavaDoc currentFrame;
43     JInternalFrame JavaDoc initialFrame;
44
45     public void activateFrame(JInternalFrame JavaDoc f) {
46         try {
47             super.activateFrame(f);
48
49             if (currentFrame != null && f != currentFrame) {
50                 // If the current frame is maximized, transfer that
51
// attribute to the frame being activated.
52
if (currentFrame.isMaximum() &&
53             (f.getClientProperty("JInternalFrame.frameType") !=
54             "optionDialog") ) {
55                     //Special case. If key binding was used to select next
56
//frame instead of minimizing the icon via the minimize
57
//icon.
58
if (!currentFrame.isIcon()) {
59                         currentFrame.setMaximum(false);
60                     }
61                     if (f.isMaximizable()) {
62                         if (!f.isMaximum()) {
63                             f.setMaximum(true);
64                         } else if (f.isMaximum() && f.isIcon()) {
65                             f.setIcon(false);
66                         } else {
67                             f.setMaximum(false);
68                         }
69                     }
70                 }
71                 if (currentFrame.isSelected()) {
72                     currentFrame.setSelected(false);
73                 }
74             }
75
76             if (!f.isSelected()) {
77                 f.setSelected(true);
78             }
79             currentFrame = f;
80         } catch (PropertyVetoException JavaDoc e) {}
81     }
82
83 }
84
Popular Tags