author | mlapshin |
Mon, 07 Jul 2008 16:56:23 +0400 | |
changeset 1277 | 61e297d24425 |
permissions | -rw-r--r-- |
1277
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
1 |
/* |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
2 |
* Copyright 1997-2008 Sun Microsystems, Inc. All Rights Reserved. |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
4 |
* |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. Sun designates this |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
8 |
* particular file as subject to the "Classpath" exception as provided |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
9 |
* by Sun in the LICENSE file that accompanied this code. |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
10 |
* |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
11 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
13 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
14 |
* version 2 for more details (a copy is included in the LICENSE file that |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
15 |
* accompanied this code). |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
16 |
* |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
17 |
* You should have received a copy of the GNU General Public License version |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
18 |
* 2 along with this work; if not, write to the Free Software Foundation, |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
19 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
20 |
* |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
21 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
22 |
* CA 95054 USA or visit www.sun.com if you need additional information or |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
23 |
* have any questions. |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
24 |
*/ |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
25 |
|
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
26 |
package javax.swing.plaf.basic; |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
27 |
|
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
28 |
import javax.swing.*; |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
29 |
import java.awt.*; |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
30 |
import java.awt.event.*; |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
31 |
import java.beans.*; |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
32 |
|
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
33 |
/** |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
34 |
* DesktopIconMover is intended to move desktop icon |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
35 |
* when parent window is resized. |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
36 |
*/ |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
37 |
class DesktopIconMover implements ComponentListener, PropertyChangeListener { |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
38 |
private Component parent; |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
39 |
private JInternalFrame frame; // if not null, DesktopIconMover(frame) |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
40 |
// constructor was used |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
41 |
private JInternalFrame.JDesktopIcon icon; |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
42 |
private Rectangle parentBounds; |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
43 |
private boolean componentListenerAdded = false; |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
44 |
|
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
45 |
public DesktopIconMover(JInternalFrame frame) { |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
46 |
if (frame == null) { |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
47 |
throw new NullPointerException("Frame cannot be null"); |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
48 |
} |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
49 |
this.frame = frame; |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
50 |
this.icon = frame.getDesktopIcon(); |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
51 |
if (icon == null) { |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
52 |
throw new NullPointerException( |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
53 |
"frame.getDesktopIcon() cannot be null"); |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
54 |
} |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
55 |
this.parent = frame.getParent(); |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
56 |
if (this.parent != null) { |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
57 |
parentBounds = this.parent.getBounds(); |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
58 |
} |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
59 |
} |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
60 |
|
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
61 |
public DesktopIconMover(JInternalFrame.JDesktopIcon icon) { |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
62 |
if (icon == null) { |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
63 |
throw new NullPointerException("Icon cannot be null"); |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
64 |
} |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
65 |
this.icon = icon; |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
66 |
this.parent = icon.getParent(); |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
67 |
if (this.parent != null) { |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
68 |
parentBounds = this.parent.getBounds(); |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
69 |
} |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
70 |
} |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
71 |
|
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
72 |
public void installListeners() { |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
73 |
if (frame != null) { |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
74 |
frame.addPropertyChangeListener(this); |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
75 |
} else { |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
76 |
icon.addPropertyChangeListener(this); |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
77 |
} |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
78 |
addComponentListener(); |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
79 |
} |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
80 |
|
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
81 |
public void uninstallListeners() { |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
82 |
if (frame != null) { |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
83 |
frame.removePropertyChangeListener(this); |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
84 |
} else { |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
85 |
icon.removePropertyChangeListener(this); |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
86 |
} |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
87 |
removeComponentListener(); |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
88 |
} |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
89 |
|
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
90 |
public void propertyChange(PropertyChangeEvent evt) { |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
91 |
String propName = evt.getPropertyName(); |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
92 |
if ("ancestor".equals(propName)) { |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
93 |
Component newAncestor = (Component) evt.getNewValue(); |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
94 |
|
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
95 |
// Remove component listener if parent is changing |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
96 |
Component probablyNewParent = getCurrentParent(); |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
97 |
if ((probablyNewParent != null) && |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
98 |
(!probablyNewParent.equals(parent))) { |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
99 |
removeComponentListener(); |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
100 |
parent = probablyNewParent; |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
101 |
} |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
102 |
|
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
103 |
if (newAncestor == null) { |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
104 |
removeComponentListener(); |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
105 |
} else { |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
106 |
addComponentListener(); |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
107 |
} |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
108 |
|
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
109 |
// Update parentBounds |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
110 |
if (parent != null) { |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
111 |
parentBounds = parent.getBounds(); |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
112 |
} else { |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
113 |
parentBounds = null; |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
114 |
} |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
115 |
} else if (JInternalFrame.IS_CLOSED_PROPERTY.equals(propName)) { |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
116 |
removeComponentListener(); |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
117 |
} |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
118 |
} |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
119 |
|
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
120 |
private void addComponentListener() { |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
121 |
if (!componentListenerAdded && (parent != null)) { |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
122 |
parent.addComponentListener(this); |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
123 |
componentListenerAdded = true; |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
124 |
} |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
125 |
} |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
126 |
|
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
127 |
private void removeComponentListener() { |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
128 |
if ((parent != null) && componentListenerAdded) { |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
129 |
parent.removeComponentListener(this); |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
130 |
componentListenerAdded = false; |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
131 |
} |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
132 |
} |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
133 |
|
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
134 |
private Component getCurrentParent() { |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
135 |
if (frame != null) { |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
136 |
return frame.getParent(); |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
137 |
} else { |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
138 |
return icon.getParent(); |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
139 |
} |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
140 |
} |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
141 |
|
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
142 |
public void componentResized(ComponentEvent e) { |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
143 |
if ((parent == null) || (parentBounds == null)) { |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
144 |
return; |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
145 |
} |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
146 |
|
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
147 |
Rectangle parentNewBounds = parent.getBounds(); |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
148 |
if ((parentNewBounds == null) || parentNewBounds.equals(parentBounds)) { |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
149 |
return; |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
150 |
} |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
151 |
|
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
152 |
// Move desktop icon only in up-down direction |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
153 |
int newIconY = icon.getLocation().y + |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
154 |
(parentNewBounds.height - parentBounds.height); |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
155 |
icon.setLocation(icon.getLocation().x, newIconY); |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
156 |
|
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
157 |
parentBounds = parentNewBounds; |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
158 |
} |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
159 |
|
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
160 |
public void componentMoved(ComponentEvent e) { |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
161 |
} |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
162 |
|
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
163 |
public void componentShown(ComponentEvent e) { |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
164 |
} |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
165 |
|
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
166 |
public void componentHidden(ComponentEvent e) { |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
167 |
} |
61e297d24425
6647340: Minimized JInternalFrame icons appear in incorrect positions if the main frame is resized
mlapshin
parents:
diff
changeset
|
168 |
} |