author | darcy |
Mon, 10 Mar 2014 13:54:25 -0700 | |
changeset 23632 | cd7a34d12e8c |
parent 5506 | 202f599c92aa |
permissions | -rw-r--r-- |
2 | 1 |
/* |
23632
cd7a34d12e8c
8033908: Fix serial lint warnings in com.sun.java.swing.plaf
darcy
parents:
5506
diff
changeset
|
2 |
* Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. |
2 | 3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 |
* |
|
5 |
* This code is free software; you can redistribute it and/or modify it |
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
|
5506 | 7 |
* published by the Free Software Foundation. Oracle designates this |
2 | 8 |
* particular file as subject to the "Classpath" exception as provided |
5506 | 9 |
* by Oracle in the LICENSE file that accompanied this code. |
2 | 10 |
* |
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
|
15 |
* accompanied this code). |
|
16 |
* |
|
17 |
* You should have received a copy of the GNU General Public License version |
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 |
* |
|
5506 | 21 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
22 |
* or visit www.oracle.com if you need additional information or have any |
|
23 |
* questions. |
|
2 | 24 |
*/ |
25 |
||
26 |
||
27 |
package com.sun.java.swing.plaf.windows; |
|
28 |
||
29 |
import javax.swing.DefaultDesktopManager; |
|
30 |
import javax.swing.JInternalFrame; |
|
31 |
import javax.swing.JLayeredPane; |
|
32 |
import java.awt.Component; |
|
33 |
import java.awt.Container; |
|
34 |
import java.awt.Dimension; |
|
35 |
import java.beans.PropertyVetoException; |
|
36 |
import java.util.Vector; |
|
37 |
import java.lang.ref.WeakReference; |
|
38 |
||
39 |
/** |
|
40 |
* This class implements a DesktopManager which more closely follows |
|
41 |
* the MDI model than the DefaultDesktopManager. Unlike the |
|
42 |
* DefaultDesktopManager policy, MDI requires that the selected |
|
43 |
* and activated child frames are the same, and that that frame |
|
44 |
* always be the top-most window. |
|
45 |
* <p> |
|
46 |
* The maximized state is managed by the DesktopManager with MDI, |
|
47 |
* instead of just being a property of the individual child frame. |
|
48 |
* This means that if the currently selected window is maximized |
|
49 |
* and another window is selected, that new window will be maximized. |
|
50 |
* |
|
51 |
* @see javax.swing.DefaultDesktopManager |
|
52 |
* @author Thomas Ball |
|
53 |
*/ |
|
23632
cd7a34d12e8c
8033908: Fix serial lint warnings in com.sun.java.swing.plaf
darcy
parents:
5506
diff
changeset
|
54 |
@SuppressWarnings("serial") // JDK-implementation class |
2 | 55 |
public class WindowsDesktopManager extends DefaultDesktopManager |
56 |
implements java.io.Serializable, javax.swing.plaf.UIResource { |
|
57 |
||
58 |
/* The frame which is currently selected/activated. |
|
59 |
* We store this value to enforce MDI's single-selection model. |
|
60 |
*/ |
|
61 |
private WeakReference<JInternalFrame> currentFrameRef; |
|
62 |
||
63 |
public void activateFrame(JInternalFrame f) { |
|
64 |
JInternalFrame currentFrame = currentFrameRef != null ? |
|
65 |
currentFrameRef.get() : null; |
|
66 |
try { |
|
67 |
super.activateFrame(f); |
|
68 |
if (currentFrame != null && f != currentFrame) { |
|
69 |
// If the current frame is maximized, transfer that |
|
70 |
// attribute to the frame being activated. |
|
71 |
if (currentFrame.isMaximum() && |
|
72 |
(f.getClientProperty("JInternalFrame.frameType") != |
|
73 |
"optionDialog") ) { |
|
74 |
//Special case. If key binding was used to select next |
|
75 |
//frame instead of minimizing the icon via the minimize |
|
76 |
//icon. |
|
77 |
if (!currentFrame.isIcon()) { |
|
78 |
currentFrame.setMaximum(false); |
|
79 |
if (f.isMaximizable()) { |
|
80 |
if (!f.isMaximum()) { |
|
81 |
f.setMaximum(true); |
|
82 |
} else if (f.isMaximum() && f.isIcon()) { |
|
83 |
f.setIcon(false); |
|
84 |
} else { |
|
85 |
f.setMaximum(false); |
|
86 |
} |
|
87 |
} |
|
88 |
} |
|
89 |
} |
|
90 |
if (currentFrame.isSelected()) { |
|
91 |
currentFrame.setSelected(false); |
|
92 |
} |
|
93 |
} |
|
94 |
||
95 |
if (!f.isSelected()) { |
|
96 |
f.setSelected(true); |
|
97 |
} |
|
98 |
} catch (PropertyVetoException e) {} |
|
99 |
if (f != currentFrame) { |
|
1290
da8902cd496c
6727661: Code improvement and warnings removing from the swing/plaf packages
rupashka
parents:
2
diff
changeset
|
100 |
currentFrameRef = new WeakReference<JInternalFrame>(f); |
2 | 101 |
} |
102 |
} |
|
103 |
||
104 |
} |