author | rchamyal |
Fri, 11 Mar 2016 10:57:47 +0530 | |
changeset 36868 | 9d0d667bff5c |
parent 36464 | 1b3f6e14e5ec |
child 39538 | 8477ce4d6628 |
permissions | -rw-r--r-- |
2 | 1 |
/* |
22567
5816a47fa4dd
8032047: Fix static lint warnings in client libraries
darcy
parents:
9035
diff
changeset
|
2 |
* Copyright (c) 1997, 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 javax.swing; |
|
28 |
||
5587
72871be64138
6786238: api/javax_swing/DefaultDesktopManager/descriptions.html#xxxFrame Fails with NPE since 6u12 b02
alexp
parents:
3288
diff
changeset
|
29 |
import com.sun.awt.AWTUtilities; |
72871be64138
6786238: api/javax_swing/DefaultDesktopManager/descriptions.html#xxxFrame Fails with NPE since 6u12 b02
alexp
parents:
3288
diff
changeset
|
30 |
import sun.awt.AWTAccessor; |
72871be64138
6786238: api/javax_swing/DefaultDesktopManager/descriptions.html#xxxFrame Fails with NPE since 6u12 b02
alexp
parents:
3288
diff
changeset
|
31 |
import sun.awt.SunToolkit; |
72871be64138
6786238: api/javax_swing/DefaultDesktopManager/descriptions.html#xxxFrame Fails with NPE since 6u12 b02
alexp
parents:
3288
diff
changeset
|
32 |
|
2 | 33 |
import java.awt.*; |
34 |
import java.beans.PropertyVetoException; |
|
2808
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2
diff
changeset
|
35 |
|
2 | 36 |
/** This is an implementation of the <code>DesktopManager</code>. |
37 |
* It currently implements the basic behaviors for managing |
|
38 |
* <code>JInternalFrame</code>s in an arbitrary parent. |
|
39 |
* <code>JInternalFrame</code>s that are not children of a |
|
40 |
* <code>JDesktop</code> will use this component |
|
41 |
* to handle their desktop-like actions. |
|
42 |
* <p>This class provides a policy for the various JInternalFrame methods, |
|
43 |
* it is not meant to be called directly rather the various JInternalFrame |
|
44 |
* methods will call into the DesktopManager.</p> |
|
45 |
* @see JDesktopPane |
|
46 |
* @see JInternalFrame |
|
47 |
* @author David Kloba |
|
48 |
* @author Steve Wilson |
|
25201
4adc75e0c4e5
8046485: Add missing @since tag under javax.swing.*
henryjen
parents:
23697
diff
changeset
|
49 |
* @since 1.2 |
2 | 50 |
*/ |
23697 | 51 |
@SuppressWarnings("serial") // No Interesting Non-Transient State |
2 | 52 |
public class DefaultDesktopManager implements DesktopManager, java.io.Serializable { |
32865
f9cb6e427f9e
8136783: Run blessed-modifier-order script on java.desktop
prr
parents:
25859
diff
changeset
|
53 |
static final String HAS_BEEN_ICONIFIED_PROPERTY = "wasIconOnce"; |
2 | 54 |
|
32865
f9cb6e427f9e
8136783: Run blessed-modifier-order script on java.desktop
prr
parents:
25859
diff
changeset
|
55 |
static final int DEFAULT_DRAG_MODE = 0; |
f9cb6e427f9e
8136783: Run blessed-modifier-order script on java.desktop
prr
parents:
25859
diff
changeset
|
56 |
static final int OUTLINE_DRAG_MODE = 1; |
f9cb6e427f9e
8136783: Run blessed-modifier-order script on java.desktop
prr
parents:
25859
diff
changeset
|
57 |
static final int FASTER_DRAG_MODE = 2; |
2 | 58 |
|
59 |
int dragMode = DEFAULT_DRAG_MODE; |
|
60 |
||
61 |
private transient Rectangle currentBounds = null; |
|
62 |
private transient Graphics desktopGraphics = null; |
|
63 |
private transient Rectangle desktopBounds = null; |
|
64 |
private transient Rectangle[] floatingItems = {}; |
|
65 |
||
66 |
/** |
|
67 |
* Set to true when the user actually drags a frame vs clicks on it |
|
68 |
* to start the drag operation. This is only used when dragging with |
|
69 |
* FASTER_DRAG_MODE. |
|
70 |
*/ |
|
71 |
private transient boolean didDrag; |
|
72 |
||
73 |
/** Normally this method will not be called. If it is, it |
|
25760
7955db32d6b0
8046597: fix doclint issues in swing classes, part 4 of 4
ssides
parents:
25386
diff
changeset
|
74 |
* tries to determine the appropriate parent from the desktopIcon of the frame. |
2 | 75 |
* Will remove the desktopIcon from its parent if it successfully adds the frame. |
76 |
*/ |
|
77 |
public void openFrame(JInternalFrame f) { |
|
78 |
if(f.getDesktopIcon().getParent() != null) { |
|
79 |
f.getDesktopIcon().getParent().add(f); |
|
80 |
removeIconFor(f); |
|
81 |
} |
|
82 |
} |
|
83 |
||
84 |
/** |
|
85 |
* Removes the frame, and, if necessary, the |
|
86 |
* <code>desktopIcon</code>, from its parent. |
|
87 |
* @param f the <code>JInternalFrame</code> to be removed |
|
88 |
*/ |
|
89 |
public void closeFrame(JInternalFrame f) { |
|
90 |
JDesktopPane d = f.getDesktopPane(); |
|
91 |
if (d == null) { |
|
92 |
return; |
|
93 |
} |
|
94 |
boolean findNext = f.isSelected(); |
|
95 |
Container c = f.getParent(); |
|
96 |
JInternalFrame nextFrame = null; |
|
97 |
if (findNext) { |
|
98 |
nextFrame = d.getNextFrame(f); |
|
99 |
try { f.setSelected(false); } catch (PropertyVetoException e2) { } |
|
100 |
} |
|
101 |
if(c != null) { |
|
102 |
c.remove(f); // Removes the focus. |
|
103 |
c.repaint(f.getX(), f.getY(), f.getWidth(), f.getHeight()); |
|
104 |
} |
|
105 |
removeIconFor(f); |
|
106 |
if(f.getNormalBounds() != null) |
|
107 |
f.setNormalBounds(null); |
|
108 |
if(wasIcon(f)) |
|
109 |
setWasIcon(f, null); |
|
110 |
if (nextFrame != null) { |
|
111 |
try { nextFrame.setSelected(true); } |
|
112 |
catch (PropertyVetoException e2) { } |
|
113 |
} else if (findNext && d.getComponentCount() == 0) { |
|
114 |
// It was selected and was the last component on the desktop. |
|
115 |
d.requestFocus(); |
|
116 |
} |
|
117 |
} |
|
118 |
||
119 |
/** |
|
120 |
* Resizes the frame to fill its parents bounds. |
|
121 |
* @param f the frame to be resized |
|
122 |
*/ |
|
123 |
public void maximizeFrame(JInternalFrame f) { |
|
124 |
if (f.isIcon()) { |
|
125 |
try { |
|
126 |
// In turn calls deiconifyFrame in the desktop manager. |
|
127 |
// That method will handle the maximization of the frame. |
|
128 |
f.setIcon(false); |
|
129 |
} catch (PropertyVetoException e2) { |
|
130 |
} |
|
131 |
} else { |
|
36868
9d0d667bff5c
8145896: JInternalFrame setMaximum before adding to desktop throws null pointer exception
rchamyal
parents:
36464
diff
changeset
|
132 |
Container c = f.getParent(); |
9d0d667bff5c
8145896: JInternalFrame setMaximum before adding to desktop throws null pointer exception
rchamyal
parents:
36464
diff
changeset
|
133 |
if (c == null) { |
9d0d667bff5c
8145896: JInternalFrame setMaximum before adding to desktop throws null pointer exception
rchamyal
parents:
36464
diff
changeset
|
134 |
return; |
9d0d667bff5c
8145896: JInternalFrame setMaximum before adding to desktop throws null pointer exception
rchamyal
parents:
36464
diff
changeset
|
135 |
} |
2 | 136 |
f.setNormalBounds(f.getBounds()); |
36868
9d0d667bff5c
8145896: JInternalFrame setMaximum before adding to desktop throws null pointer exception
rchamyal
parents:
36464
diff
changeset
|
137 |
Rectangle desktopBounds = c.getBounds(); |
2 | 138 |
setBoundsForFrame(f, 0, 0, |
139 |
desktopBounds.width, desktopBounds.height); |
|
140 |
} |
|
141 |
||
142 |
// Set the maximized frame as selected. |
|
143 |
try { |
|
144 |
f.setSelected(true); |
|
145 |
} catch (PropertyVetoException e2) { |
|
146 |
} |
|
147 |
} |
|
148 |
||
149 |
/** |
|
150 |
* Restores the frame back to its size and position prior |
|
151 |
* to a <code>maximizeFrame</code> call. |
|
152 |
* @param f the <code>JInternalFrame</code> to be restored |
|
153 |
*/ |
|
154 |
public void minimizeFrame(JInternalFrame f) { |
|
155 |
// If the frame was an icon restore it back to an icon. |
|
156 |
if (f.isIcon()) { |
|
157 |
iconifyFrame(f); |
|
158 |
return; |
|
159 |
} |
|
160 |
||
161 |
if ((f.getNormalBounds()) != null) { |
|
162 |
Rectangle r = f.getNormalBounds(); |
|
163 |
f.setNormalBounds(null); |
|
164 |
try { f.setSelected(true); } catch (PropertyVetoException e2) { } |
|
165 |
setBoundsForFrame(f, r.x, r.y, r.width, r.height); |
|
166 |
} |
|
167 |
} |
|
168 |
||
169 |
/** |
|
170 |
* Removes the frame from its parent and adds its |
|
171 |
* <code>desktopIcon</code> to the parent. |
|
172 |
* @param f the <code>JInternalFrame</code> to be iconified |
|
173 |
*/ |
|
174 |
public void iconifyFrame(JInternalFrame f) { |
|
175 |
JInternalFrame.JDesktopIcon desktopIcon; |
|
176 |
Container c = f.getParent(); |
|
177 |
JDesktopPane d = f.getDesktopPane(); |
|
178 |
boolean findNext = f.isSelected(); |
|
179 |
desktopIcon = f.getDesktopIcon(); |
|
180 |
if(!wasIcon(f)) { |
|
181 |
Rectangle r = getBoundsForIconOf(f); |
|
182 |
desktopIcon.setBounds(r.x, r.y, r.width, r.height); |
|
8524
f2fac94f2434
6826074: JScrollPane does not revalidate the component hierarchy after scrolling
alexp
parents:
7762
diff
changeset
|
183 |
// we must validate the hierarchy to not break the hw/lw mixing |
f2fac94f2434
6826074: JScrollPane does not revalidate the component hierarchy after scrolling
alexp
parents:
7762
diff
changeset
|
184 |
desktopIcon.revalidate(); |
2 | 185 |
setWasIcon(f, Boolean.TRUE); |
186 |
} |
|
187 |
||
188 |
if (c == null || d == null) { |
|
189 |
return; |
|
190 |
} |
|
191 |
||
192 |
if (c instanceof JLayeredPane) { |
|
193 |
JLayeredPane lp = (JLayeredPane)c; |
|
22567
5816a47fa4dd
8032047: Fix static lint warnings in client libraries
darcy
parents:
9035
diff
changeset
|
194 |
int layer = JLayeredPane.getLayer(f); |
5816a47fa4dd
8032047: Fix static lint warnings in client libraries
darcy
parents:
9035
diff
changeset
|
195 |
JLayeredPane.putLayer(desktopIcon, layer); |
2 | 196 |
} |
197 |
||
198 |
if (findNext) { |
|
199 |
if (d.selectFrame(true) == null) { |
|
200 |
// The icon is the last frame. |
|
201 |
f.restoreSubcomponentFocus(); |
|
202 |
} |
|
203 |
} |
|
35663
c118917086ed
8145060: Minimizing a JInternal frame not shifting focus to frame below it
rchamyal
parents:
32865
diff
changeset
|
204 |
d.setComponentOrderCheckingEnabled(false); |
c118917086ed
8145060: Minimizing a JInternal frame not shifting focus to frame below it
rchamyal
parents:
32865
diff
changeset
|
205 |
c.remove(f); |
c118917086ed
8145060: Minimizing a JInternal frame not shifting focus to frame below it
rchamyal
parents:
32865
diff
changeset
|
206 |
c.add(desktopIcon); |
c118917086ed
8145060: Minimizing a JInternal frame not shifting focus to frame below it
rchamyal
parents:
32865
diff
changeset
|
207 |
d.setComponentOrderCheckingEnabled(true); |
c118917086ed
8145060: Minimizing a JInternal frame not shifting focus to frame below it
rchamyal
parents:
32865
diff
changeset
|
208 |
c.repaint(f.getX(), f.getY(), f.getWidth(), f.getHeight()); |
2 | 209 |
} |
210 |
||
211 |
/** |
|
212 |
* Removes the desktopIcon from its parent and adds its frame |
|
213 |
* to the parent. |
|
214 |
* @param f the <code>JInternalFrame</code> to be de-iconified |
|
215 |
*/ |
|
216 |
public void deiconifyFrame(JInternalFrame f) { |
|
217 |
JInternalFrame.JDesktopIcon desktopIcon = f.getDesktopIcon(); |
|
218 |
Container c = desktopIcon.getParent(); |
|
219 |
JDesktopPane d = f.getDesktopPane(); |
|
220 |
if (c != null && d != null) { |
|
221 |
c.add(f); |
|
222 |
// If the frame is to be restored to a maximized state make |
|
223 |
// sure it still fills the whole desktop. |
|
224 |
if (f.isMaximum()) { |
|
225 |
Rectangle desktopBounds = c.getBounds(); |
|
226 |
if (f.getWidth() != desktopBounds.width || |
|
227 |
f.getHeight() != desktopBounds.height) { |
|
228 |
setBoundsForFrame(f, 0, 0, |
|
229 |
desktopBounds.width, desktopBounds.height); |
|
230 |
} |
|
231 |
} |
|
232 |
removeIconFor(f); |
|
233 |
if (f.isSelected()) { |
|
234 |
f.moveToFront(); |
|
235 |
f.restoreSubcomponentFocus(); |
|
236 |
} |
|
237 |
else { |
|
238 |
try { |
|
239 |
f.setSelected(true); |
|
240 |
} catch (PropertyVetoException e2) {} |
|
241 |
||
242 |
} |
|
243 |
} |
|
244 |
} |
|
245 |
||
246 |
/** This will activate <b>f</b> moving it to the front. It will |
|
247 |
* set the current active frame's (if any) |
|
248 |
* <code>IS_SELECTED_PROPERTY</code> to <code>false</code>. |
|
249 |
* There can be only one active frame across all Layers. |
|
250 |
* @param f the <code>JInternalFrame</code> to be activated |
|
251 |
*/ |
|
252 |
public void activateFrame(JInternalFrame f) { |
|
253 |
Container p = f.getParent(); |
|
254 |
Component[] c; |
|
255 |
JDesktopPane d = f.getDesktopPane(); |
|
256 |
JInternalFrame currentlyActiveFrame = |
|
257 |
(d == null) ? null : d.getSelectedFrame(); |
|
258 |
// fix for bug: 4162443 |
|
259 |
if(p == null) { |
|
260 |
// If the frame is not in parent, its icon maybe, check it |
|
261 |
p = f.getDesktopIcon().getParent(); |
|
262 |
if(p == null) |
|
263 |
return; |
|
264 |
} |
|
265 |
// we only need to keep track of the currentActive InternalFrame, if any |
|
266 |
if (currentlyActiveFrame == null){ |
|
267 |
if (d != null) { d.setSelectedFrame(f);} |
|
268 |
} else if (currentlyActiveFrame != f) { |
|
269 |
// if not the same frame as the current active |
|
270 |
// we deactivate the current |
|
271 |
if (currentlyActiveFrame.isSelected()) { |
|
272 |
try { |
|
273 |
currentlyActiveFrame.setSelected(false); |
|
274 |
} |
|
275 |
catch(PropertyVetoException e2) {} |
|
276 |
} |
|
277 |
if (d != null) { d.setSelectedFrame(f);} |
|
278 |
} |
|
279 |
f.moveToFront(); |
|
280 |
} |
|
281 |
||
282 |
// implements javax.swing.DesktopManager |
|
283 |
public void deactivateFrame(JInternalFrame f) { |
|
284 |
JDesktopPane d = f.getDesktopPane(); |
|
285 |
JInternalFrame currentlyActiveFrame = |
|
286 |
(d == null) ? null : d.getSelectedFrame(); |
|
287 |
if (currentlyActiveFrame == f) |
|
288 |
d.setSelectedFrame(null); |
|
289 |
} |
|
290 |
||
291 |
// implements javax.swing.DesktopManager |
|
292 |
public void beginDraggingFrame(JComponent f) { |
|
293 |
setupDragMode(f); |
|
294 |
||
295 |
if (dragMode == FASTER_DRAG_MODE) { |
|
296 |
Component desktop = f.getParent(); |
|
297 |
floatingItems = findFloatingItems(f); |
|
298 |
currentBounds = f.getBounds(); |
|
299 |
if (desktop instanceof JComponent) { |
|
300 |
desktopBounds = ((JComponent)desktop).getVisibleRect(); |
|
301 |
} |
|
302 |
else { |
|
303 |
desktopBounds = desktop.getBounds(); |
|
304 |
desktopBounds.x = desktopBounds.y = 0; |
|
305 |
} |
|
306 |
desktopGraphics = JComponent.safelyGetGraphics(desktop); |
|
307 |
((JInternalFrame)f).isDragging = true; |
|
308 |
didDrag = false; |
|
309 |
} |
|
310 |
||
311 |
} |
|
312 |
||
313 |
private void setupDragMode(JComponent f) { |
|
314 |
JDesktopPane p = getDesktopPane(f); |
|
315 |
Container parent = f.getParent(); |
|
316 |
dragMode = DEFAULT_DRAG_MODE; |
|
317 |
if (p != null) { |
|
318 |
String mode = (String)p.getClientProperty("JDesktopPane.dragMode"); |
|
5587
72871be64138
6786238: api/javax_swing/DefaultDesktopManager/descriptions.html#xxxFrame Fails with NPE since 6u12 b02
alexp
parents:
3288
diff
changeset
|
319 |
Window window = SwingUtilities.getWindowAncestor(f); |
72871be64138
6786238: api/javax_swing/DefaultDesktopManager/descriptions.html#xxxFrame Fails with NPE since 6u12 b02
alexp
parents:
3288
diff
changeset
|
320 |
if (window != null && !AWTUtilities.isWindowOpaque(window)) { |
72871be64138
6786238: api/javax_swing/DefaultDesktopManager/descriptions.html#xxxFrame Fails with NPE since 6u12 b02
alexp
parents:
3288
diff
changeset
|
321 |
dragMode = DEFAULT_DRAG_MODE; |
72871be64138
6786238: api/javax_swing/DefaultDesktopManager/descriptions.html#xxxFrame Fails with NPE since 6u12 b02
alexp
parents:
3288
diff
changeset
|
322 |
} else if (mode != null && mode.equals("outline")) { |
2 | 323 |
dragMode = OUTLINE_DRAG_MODE; |
324 |
} else if (mode != null && mode.equals("faster") |
|
325 |
&& f instanceof JInternalFrame |
|
326 |
&& ((JInternalFrame)f).isOpaque() && |
|
327 |
(parent == null || parent.isOpaque())) { |
|
328 |
dragMode = FASTER_DRAG_MODE; |
|
329 |
} else { |
|
330 |
if (p.getDragMode() == JDesktopPane.OUTLINE_DRAG_MODE ) { |
|
331 |
dragMode = OUTLINE_DRAG_MODE; |
|
332 |
} else if ( p.getDragMode() == JDesktopPane.LIVE_DRAG_MODE |
|
333 |
&& f instanceof JInternalFrame |
|
334 |
&& ((JInternalFrame)f).isOpaque()) { |
|
335 |
dragMode = FASTER_DRAG_MODE; |
|
336 |
} else { |
|
337 |
dragMode = DEFAULT_DRAG_MODE; |
|
338 |
} |
|
339 |
} |
|
340 |
} |
|
341 |
} |
|
342 |
||
343 |
private transient Point currentLoc = null; |
|
344 |
||
345 |
/** |
|
346 |
* Moves the visible location of the frame being dragged |
|
347 |
* to the location specified. The means by which this occurs can vary depending |
|
348 |
* on the dragging algorithm being used. The actual logical location of the frame |
|
349 |
* might not change until <code>endDraggingFrame</code> is called. |
|
350 |
*/ |
|
351 |
public void dragFrame(JComponent f, int newX, int newY) { |
|
352 |
||
353 |
if (dragMode == OUTLINE_DRAG_MODE) { |
|
354 |
JDesktopPane desktopPane = getDesktopPane(f); |
|
355 |
if (desktopPane != null){ |
|
356 |
Graphics g = JComponent.safelyGetGraphics(desktopPane); |
|
357 |
||
358 |
g.setXORMode(Color.white); |
|
359 |
if (currentLoc != null) { |
|
360 |
g.drawRect(currentLoc.x, currentLoc.y, |
|
361 |
f.getWidth()-1, f.getHeight()-1); |
|
362 |
} |
|
363 |
g.drawRect( newX, newY, f.getWidth()-1, f.getHeight()-1); |
|
7748
26e6f5fc1bdb
6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents:
5597
diff
changeset
|
364 |
/* Work around for 6635462: XOR mode may cause a SurfaceLost on first use. |
26e6f5fc1bdb
6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents:
5597
diff
changeset
|
365 |
* Swing doesn't expect that its XOR drawRect did |
26e6f5fc1bdb
6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents:
5597
diff
changeset
|
366 |
* not complete, so believes that on re-entering at |
26e6f5fc1bdb
6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents:
5597
diff
changeset
|
367 |
* the next update location, that there is an XOR rect |
26e6f5fc1bdb
6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents:
5597
diff
changeset
|
368 |
* to draw out at "currentLoc". But in fact |
26e6f5fc1bdb
6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents:
5597
diff
changeset
|
369 |
* its now got a new clean surface without that rect, |
26e6f5fc1bdb
6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents:
5597
diff
changeset
|
370 |
* so drawing it "out" in fact draws it on, leaving garbage. |
26e6f5fc1bdb
6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents:
5597
diff
changeset
|
371 |
* So only update/set currentLoc if the draw completed. |
26e6f5fc1bdb
6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents:
5597
diff
changeset
|
372 |
*/ |
26e6f5fc1bdb
6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents:
5597
diff
changeset
|
373 |
sun.java2d.SurfaceData sData = |
26e6f5fc1bdb
6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents:
5597
diff
changeset
|
374 |
((sun.java2d.SunGraphics2D)g).getSurfaceData(); |
26e6f5fc1bdb
6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents:
5597
diff
changeset
|
375 |
|
26e6f5fc1bdb
6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents:
5597
diff
changeset
|
376 |
if (!sData.isSurfaceLost()) { |
26e6f5fc1bdb
6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents:
5597
diff
changeset
|
377 |
currentLoc = new Point (newX, newY); |
26e6f5fc1bdb
6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents:
5597
diff
changeset
|
378 |
} |
26e6f5fc1bdb
6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents:
5597
diff
changeset
|
379 |
; |
2 | 380 |
g.dispose(); |
381 |
} |
|
382 |
} else if (dragMode == FASTER_DRAG_MODE) { |
|
2808
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2
diff
changeset
|
383 |
dragFrameFaster(f, newX, newY); |
2 | 384 |
} else { |
385 |
setBoundsForFrame(f, newX, newY, f.getWidth(), f.getHeight()); |
|
386 |
} |
|
387 |
} |
|
388 |
||
389 |
// implements javax.swing.DesktopManager |
|
390 |
public void endDraggingFrame(JComponent f) { |
|
391 |
if ( dragMode == OUTLINE_DRAG_MODE && currentLoc != null) { |
|
392 |
setBoundsForFrame(f, currentLoc.x, currentLoc.y, f.getWidth(), f.getHeight() ); |
|
393 |
currentLoc = null; |
|
394 |
} else if (dragMode == FASTER_DRAG_MODE) { |
|
395 |
currentBounds = null; |
|
396 |
if (desktopGraphics != null) { |
|
397 |
desktopGraphics.dispose(); |
|
398 |
desktopGraphics = null; |
|
399 |
} |
|
400 |
desktopBounds = null; |
|
401 |
((JInternalFrame)f).isDragging = false; |
|
402 |
} |
|
403 |
} |
|
404 |
||
405 |
// implements javax.swing.DesktopManager |
|
406 |
public void beginResizingFrame(JComponent f, int direction) { |
|
407 |
setupDragMode(f); |
|
408 |
} |
|
409 |
||
410 |
/** |
|
411 |
* Calls <code>setBoundsForFrame</code> with the new values. |
|
412 |
* @param f the component to be resized |
|
413 |
* @param newX the new x-coordinate |
|
414 |
* @param newY the new y-coordinate |
|
415 |
* @param newWidth the new width |
|
416 |
* @param newHeight the new height |
|
417 |
*/ |
|
418 |
public void resizeFrame(JComponent f, int newX, int newY, int newWidth, int newHeight) { |
|
419 |
||
420 |
if ( dragMode == DEFAULT_DRAG_MODE || dragMode == FASTER_DRAG_MODE ) { |
|
421 |
setBoundsForFrame(f, newX, newY, newWidth, newHeight); |
|
422 |
} else { |
|
423 |
JDesktopPane desktopPane = getDesktopPane(f); |
|
424 |
if (desktopPane != null){ |
|
425 |
Graphics g = JComponent.safelyGetGraphics(desktopPane); |
|
426 |
||
427 |
g.setXORMode(Color.white); |
|
428 |
if (currentBounds != null) { |
|
429 |
g.drawRect( currentBounds.x, currentBounds.y, currentBounds.width-1, currentBounds.height-1); |
|
430 |
} |
|
431 |
g.drawRect( newX, newY, newWidth-1, newHeight-1); |
|
7748
26e6f5fc1bdb
6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents:
5597
diff
changeset
|
432 |
|
26e6f5fc1bdb
6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents:
5597
diff
changeset
|
433 |
// Work around for 6635462, see comment in dragFrame() |
26e6f5fc1bdb
6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents:
5597
diff
changeset
|
434 |
sun.java2d.SurfaceData sData = |
26e6f5fc1bdb
6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents:
5597
diff
changeset
|
435 |
((sun.java2d.SunGraphics2D)g).getSurfaceData(); |
26e6f5fc1bdb
6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents:
5597
diff
changeset
|
436 |
if (!sData.isSurfaceLost()) { |
26e6f5fc1bdb
6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents:
5597
diff
changeset
|
437 |
currentBounds = new Rectangle (newX, newY, newWidth, newHeight); |
26e6f5fc1bdb
6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents:
5597
diff
changeset
|
438 |
} |
26e6f5fc1bdb
6635462: D3D: REGRESSION: XOR rendering is extremly slow
jgodinez
parents:
5597
diff
changeset
|
439 |
|
2 | 440 |
g.setPaintMode(); |
441 |
g.dispose(); |
|
442 |
} |
|
443 |
} |
|
444 |
||
445 |
} |
|
446 |
||
447 |
// implements javax.swing.DesktopManager |
|
448 |
public void endResizingFrame(JComponent f) { |
|
449 |
if ( dragMode == OUTLINE_DRAG_MODE && currentBounds != null) { |
|
450 |
setBoundsForFrame(f, currentBounds.x, currentBounds.y, currentBounds.width, currentBounds.height ); |
|
451 |
currentBounds = null; |
|
452 |
} |
|
453 |
} |
|
454 |
||
455 |
||
456 |
/** This moves the <code>JComponent</code> and repaints the damaged areas. */ |
|
457 |
public void setBoundsForFrame(JComponent f, int newX, int newY, int newWidth, int newHeight) { |
|
458 |
f.setBounds(newX, newY, newWidth, newHeight); |
|
8524
f2fac94f2434
6826074: JScrollPane does not revalidate the component hierarchy after scrolling
alexp
parents:
7762
diff
changeset
|
459 |
// we must validate the hierarchy to not break the hw/lw mixing |
f2fac94f2434
6826074: JScrollPane does not revalidate the component hierarchy after scrolling
alexp
parents:
7762
diff
changeset
|
460 |
f.revalidate(); |
2 | 461 |
} |
462 |
||
25386
9ef80c24fd74
8046590: fix doclint issues in swing classes, part 1 of 4
yan
parents:
25201
diff
changeset
|
463 |
/** |
9ef80c24fd74
8046590: fix doclint issues in swing classes, part 1 of 4
yan
parents:
25201
diff
changeset
|
464 |
* Convenience method to remove the desktopIcon of <b>f</b> is necessary. |
9ef80c24fd74
8046590: fix doclint issues in swing classes, part 1 of 4
yan
parents:
25201
diff
changeset
|
465 |
* |
9ef80c24fd74
8046590: fix doclint issues in swing classes, part 1 of 4
yan
parents:
25201
diff
changeset
|
466 |
* @param f the {@code JInternalFrame} for which to remove the |
9ef80c24fd74
8046590: fix doclint issues in swing classes, part 1 of 4
yan
parents:
25201
diff
changeset
|
467 |
* {@code desktopIcon} |
9ef80c24fd74
8046590: fix doclint issues in swing classes, part 1 of 4
yan
parents:
25201
diff
changeset
|
468 |
*/ |
2 | 469 |
protected void removeIconFor(JInternalFrame f) { |
470 |
JInternalFrame.JDesktopIcon di = f.getDesktopIcon(); |
|
471 |
Container c = di.getParent(); |
|
472 |
if(c != null) { |
|
473 |
c.remove(di); |
|
474 |
c.repaint(di.getX(), di.getY(), di.getWidth(), di.getHeight()); |
|
475 |
} |
|
476 |
} |
|
477 |
||
25386
9ef80c24fd74
8046590: fix doclint issues in swing classes, part 1 of 4
yan
parents:
25201
diff
changeset
|
478 |
/** |
9ef80c24fd74
8046590: fix doclint issues in swing classes, part 1 of 4
yan
parents:
25201
diff
changeset
|
479 |
* The {@code iconifyFrame()} code calls this to determine the proper bounds |
9ef80c24fd74
8046590: fix doclint issues in swing classes, part 1 of 4
yan
parents:
25201
diff
changeset
|
480 |
* for the desktopIcon. |
9ef80c24fd74
8046590: fix doclint issues in swing classes, part 1 of 4
yan
parents:
25201
diff
changeset
|
481 |
* |
9ef80c24fd74
8046590: fix doclint issues in swing classes, part 1 of 4
yan
parents:
25201
diff
changeset
|
482 |
* @param f the {@code JInternalFrame} of interest |
9ef80c24fd74
8046590: fix doclint issues in swing classes, part 1 of 4
yan
parents:
25201
diff
changeset
|
483 |
* @return a {@code Rectangle} containing bounds for the {@code desktopIcon} |
9ef80c24fd74
8046590: fix doclint issues in swing classes, part 1 of 4
yan
parents:
25201
diff
changeset
|
484 |
*/ |
2 | 485 |
protected Rectangle getBoundsForIconOf(JInternalFrame f) { |
486 |
// |
|
487 |
// Get the icon for this internal frame and its preferred size |
|
488 |
// |
|
489 |
||
490 |
JInternalFrame.JDesktopIcon icon = f.getDesktopIcon(); |
|
491 |
Dimension prefSize = icon.getPreferredSize(); |
|
492 |
// |
|
493 |
// Get the parent bounds and child components. |
|
494 |
// |
|
495 |
||
496 |
Container c = f.getParent(); |
|
497 |
if (c == null) { |
|
498 |
c = f.getDesktopIcon().getParent(); |
|
499 |
} |
|
500 |
||
501 |
if (c == null) { |
|
502 |
/* the frame has not yet been added to the parent; how about (0,0) ?*/ |
|
503 |
return new Rectangle(0, 0, prefSize.width, prefSize.height); |
|
504 |
} |
|
505 |
||
506 |
Rectangle parentBounds = c.getBounds(); |
|
507 |
Component [] components = c.getComponents(); |
|
508 |
||
509 |
||
510 |
// |
|
511 |
// Iterate through valid default icon locations and return the |
|
512 |
// first one that does not intersect any other icons. |
|
513 |
// |
|
514 |
||
515 |
Rectangle availableRectangle = null; |
|
516 |
JInternalFrame.JDesktopIcon currentIcon = null; |
|
517 |
||
518 |
int x = 0; |
|
519 |
int y = parentBounds.height - prefSize.height; |
|
520 |
int w = prefSize.width; |
|
521 |
int h = prefSize.height; |
|
522 |
||
523 |
boolean found = false; |
|
524 |
||
525 |
while (!found) { |
|
526 |
||
527 |
availableRectangle = new Rectangle(x,y,w,h); |
|
528 |
||
529 |
found = true; |
|
530 |
||
531 |
for ( int i=0; i<components.length; i++ ) { |
|
532 |
||
533 |
// |
|
534 |
// Get the icon for this component |
|
535 |
// |
|
536 |
||
537 |
if ( components[i] instanceof JInternalFrame ) { |
|
538 |
currentIcon = ((JInternalFrame)components[i]).getDesktopIcon(); |
|
539 |
} |
|
540 |
else if ( components[i] instanceof JInternalFrame.JDesktopIcon ){ |
|
541 |
currentIcon = (JInternalFrame.JDesktopIcon)components[i]; |
|
542 |
} else |
|
543 |
/* found a child that's neither an internal frame nor |
|
544 |
an icon. I don't believe this should happen, but at |
|
545 |
present it does and causes a null pointer exception. |
|
546 |
Even when that gets fixed, this code protects against |
|
547 |
the npe. hania */ |
|
548 |
continue; |
|
549 |
||
550 |
// |
|
551 |
// If this icon intersects the current location, get next location. |
|
552 |
// |
|
553 |
||
554 |
if ( !currentIcon.equals(icon) ) { |
|
555 |
if ( availableRectangle.intersects(currentIcon.getBounds()) ) { |
|
556 |
found = false; |
|
557 |
break; |
|
558 |
} |
|
559 |
} |
|
560 |
} |
|
561 |
||
562 |
if (currentIcon == null) |
|
563 |
/* didn't find any useful children above. This probably shouldn't |
|
564 |
happen, but this check protects against an npe if it ever does |
|
565 |
(and it's happening now) */ |
|
566 |
return availableRectangle; |
|
567 |
||
568 |
x += currentIcon.getBounds().width; |
|
569 |
||
570 |
if ( x + w > parentBounds.width ) { |
|
571 |
x = 0; |
|
572 |
y -= h; |
|
573 |
} |
|
574 |
} |
|
575 |
||
576 |
return(availableRectangle); |
|
577 |
} |
|
578 |
||
579 |
/** |
|
580 |
* Stores the bounds of the component just before a maximize call. |
|
581 |
* @param f the component about to be resized |
|
582 |
* @param r the normal bounds to be saved away |
|
583 |
*/ |
|
584 |
protected void setPreviousBounds(JInternalFrame f, Rectangle r) { |
|
585 |
f.setNormalBounds(r); |
|
586 |
} |
|
587 |
||
588 |
/** |
|
589 |
* Gets the normal bounds of the component prior to the component |
|
590 |
* being maximized. |
|
591 |
* @param f the <code>JInternalFrame</code> of interest |
|
592 |
* @return the normal bounds of the component |
|
593 |
*/ |
|
594 |
protected Rectangle getPreviousBounds(JInternalFrame f) { |
|
595 |
return f.getNormalBounds(); |
|
596 |
} |
|
597 |
||
598 |
/** |
|
599 |
* Sets that the component has been iconized and the bounds of the |
|
600 |
* <code>desktopIcon</code> are valid. |
|
25386
9ef80c24fd74
8046590: fix doclint issues in swing classes, part 1 of 4
yan
parents:
25201
diff
changeset
|
601 |
* |
9ef80c24fd74
8046590: fix doclint issues in swing classes, part 1 of 4
yan
parents:
25201
diff
changeset
|
602 |
* @param f the {@code JInternalFrame} of interest |
9ef80c24fd74
8046590: fix doclint issues in swing classes, part 1 of 4
yan
parents:
25201
diff
changeset
|
603 |
* @param value a {@code Boolean} signifying if component has been iconized |
2 | 604 |
*/ |
605 |
protected void setWasIcon(JInternalFrame f, Boolean value) { |
|
606 |
if (value != null) { |
|
607 |
f.putClientProperty(HAS_BEEN_ICONIFIED_PROPERTY, value); |
|
608 |
} |
|
609 |
} |
|
610 |
||
611 |
/** |
|
612 |
* Returns <code>true</code> if the component has been iconized |
|
613 |
* and the bounds of the <code>desktopIcon</code> are valid, |
|
614 |
* otherwise returns <code>false</code>. |
|
615 |
* |
|
616 |
* @param f the <code>JInternalFrame</code> of interest |
|
617 |
* @return <code>true</code> if the component has been iconized; |
|
618 |
* otherwise returns <code>false</code> |
|
619 |
*/ |
|
620 |
protected boolean wasIcon(JInternalFrame f) { |
|
621 |
return (f.getClientProperty(HAS_BEEN_ICONIFIED_PROPERTY) == Boolean.TRUE); |
|
622 |
} |
|
623 |
||
624 |
||
625 |
JDesktopPane getDesktopPane( JComponent frame ) { |
|
626 |
JDesktopPane pane = null; |
|
627 |
Component c = frame.getParent(); |
|
628 |
||
629 |
// Find the JDesktopPane |
|
630 |
while ( pane == null ) { |
|
631 |
if ( c instanceof JDesktopPane ) { |
|
632 |
pane = (JDesktopPane)c; |
|
633 |
} |
|
634 |
else if ( c == null ) { |
|
635 |
break; |
|
636 |
} |
|
637 |
else { |
|
638 |
c = c.getParent(); |
|
639 |
} |
|
640 |
} |
|
641 |
||
642 |
return pane; |
|
643 |
} |
|
644 |
||
645 |
||
646 |
// =========== stuff for faster frame dragging =================== |
|
647 |
||
648 |
private void dragFrameFaster(JComponent f, int newX, int newY) { |
|
649 |
||
650 |
Rectangle previousBounds = new Rectangle(currentBounds.x, |
|
651 |
currentBounds.y, |
|
652 |
currentBounds.width, |
|
653 |
currentBounds.height); |
|
654 |
||
655 |
// move the frame |
|
656 |
currentBounds.x = newX; |
|
657 |
currentBounds.y = newY; |
|
658 |
||
659 |
if (didDrag) { |
|
660 |
// Only initiate cleanup if we have actually done a drag. |
|
661 |
emergencyCleanup(f); |
|
662 |
} |
|
663 |
else { |
|
664 |
didDrag = true; |
|
665 |
// We reset the danger field as until now we haven't actually |
|
666 |
// moved the internal frame so we don't need to initiate repaint. |
|
667 |
((JInternalFrame)f).danger = false; |
|
668 |
} |
|
669 |
||
670 |
boolean floaterCollision = isFloaterCollision(previousBounds, currentBounds); |
|
671 |
||
672 |
JComponent parent = (JComponent)f.getParent(); |
|
673 |
Rectangle visBounds = previousBounds.intersection(desktopBounds); |
|
674 |
||
675 |
RepaintManager currentManager = RepaintManager.currentManager(f); |
|
676 |
||
677 |
currentManager.beginPaint(); |
|
678 |
try { |
|
679 |
if(!floaterCollision) { |
|
680 |
currentManager.copyArea(parent, desktopGraphics, visBounds.x, |
|
681 |
visBounds.y, |
|
682 |
visBounds.width, |
|
683 |
visBounds.height, |
|
684 |
newX - previousBounds.x, |
|
685 |
newY - previousBounds.y, |
|
686 |
true); |
|
687 |
} |
|
688 |
||
689 |
f.setBounds(currentBounds); |
|
690 |
||
23280
df31f522531f
8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents:
22567
diff
changeset
|
691 |
if (!floaterCollision) { |
df31f522531f
8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents:
22567
diff
changeset
|
692 |
Rectangle r = currentBounds; |
df31f522531f
8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents:
22567
diff
changeset
|
693 |
currentManager.notifyRepaintPerformed(parent, r.x, r.y, r.width, r.height); |
df31f522531f
8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents:
22567
diff
changeset
|
694 |
} |
df31f522531f
8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents:
22567
diff
changeset
|
695 |
|
2 | 696 |
if(floaterCollision) { |
697 |
// since we couldn't blit we just redraw as fast as possible |
|
698 |
// the isDragging mucking is to avoid activating emergency |
|
699 |
// cleanup |
|
700 |
((JInternalFrame)f).isDragging = false; |
|
701 |
parent.paintImmediately(currentBounds); |
|
702 |
((JInternalFrame)f).isDragging = true; |
|
703 |
} |
|
704 |
||
705 |
// fake out the repaint manager. We'll take care of everything |
|
706 |
||
707 |
currentManager.markCompletelyClean(parent); |
|
708 |
currentManager.markCompletelyClean(f); |
|
709 |
||
710 |
// compute the minimal newly exposed area |
|
711 |
// if the rects intersect then we use computeDifference. Otherwise |
|
712 |
// we'll repaint the entire previous bounds |
|
713 |
Rectangle[] dirtyRects = null; |
|
714 |
if ( previousBounds.intersects(currentBounds) ) { |
|
715 |
dirtyRects = SwingUtilities.computeDifference(previousBounds, |
|
716 |
currentBounds); |
|
717 |
} else { |
|
718 |
dirtyRects = new Rectangle[1]; |
|
719 |
dirtyRects[0] = previousBounds; |
|
720 |
}; |
|
721 |
||
722 |
// Fix the damage |
|
723 |
for (int i = 0; i < dirtyRects.length; i++) { |
|
724 |
parent.paintImmediately(dirtyRects[i]); |
|
23280
df31f522531f
8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents:
22567
diff
changeset
|
725 |
Rectangle r = dirtyRects[i]; |
df31f522531f
8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents:
22567
diff
changeset
|
726 |
currentManager.notifyRepaintPerformed(parent, r.x, r.y, r.width, r.height); |
2 | 727 |
} |
728 |
||
729 |
// new areas of blit were exposed |
|
730 |
if ( !(visBounds.equals(previousBounds)) ) { |
|
731 |
dirtyRects = SwingUtilities.computeDifference(previousBounds, |
|
732 |
desktopBounds); |
|
733 |
for (int i = 0; i < dirtyRects.length; i++) { |
|
734 |
dirtyRects[i].x += newX - previousBounds.x; |
|
735 |
dirtyRects[i].y += newY - previousBounds.y; |
|
736 |
((JInternalFrame)f).isDragging = false; |
|
737 |
parent.paintImmediately(dirtyRects[i]); |
|
738 |
((JInternalFrame)f).isDragging = true; |
|
23280
df31f522531f
8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents:
22567
diff
changeset
|
739 |
Rectangle r = dirtyRects[i]; |
df31f522531f
8033233: [JLightweightFrame] support default JViewport BLIT_SCROLL_MODE
ant
parents:
22567
diff
changeset
|
740 |
currentManager.notifyRepaintPerformed(parent, r.x, r.y, r.width, r.height); |
2 | 741 |
} |
742 |
||
743 |
} |
|
744 |
} finally { |
|
745 |
currentManager.endPaint(); |
|
746 |
} |
|
2808
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2
diff
changeset
|
747 |
|
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2
diff
changeset
|
748 |
// update window if it's non-opaque |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2
diff
changeset
|
749 |
Window topLevel = SwingUtilities.getWindowAncestor(f); |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2
diff
changeset
|
750 |
Toolkit tk = Toolkit.getDefaultToolkit(); |
3237 | 751 |
if (!topLevel.isOpaque() && |
2808
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2
diff
changeset
|
752 |
(tk instanceof SunToolkit) && |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2
diff
changeset
|
753 |
((SunToolkit)tk).needUpdateWindow()) |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2
diff
changeset
|
754 |
{ |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2
diff
changeset
|
755 |
AWTAccessor.getWindowAccessor().updateWindow(topLevel); |
a139a919f645
6794764: Translucent windows are completely repainted on every paint event, on Windows
art
parents:
2
diff
changeset
|
756 |
} |
2 | 757 |
} |
758 |
||
759 |
private boolean isFloaterCollision(Rectangle moveFrom, Rectangle moveTo) { |
|
760 |
if (floatingItems.length == 0) { |
|
761 |
// System.out.println("no floaters"); |
|
762 |
return false; |
|
763 |
} |
|
764 |
||
765 |
for (int i = 0; i < floatingItems.length; i++) { |
|
766 |
boolean intersectsFrom = moveFrom.intersects(floatingItems[i]); |
|
767 |
if (intersectsFrom) { |
|
768 |
return true; |
|
769 |
} |
|
770 |
boolean intersectsTo = moveTo.intersects(floatingItems[i]); |
|
771 |
if (intersectsTo) { |
|
772 |
return true; |
|
773 |
} |
|
774 |
} |
|
775 |
||
776 |
return false; |
|
777 |
} |
|
778 |
||
779 |
private Rectangle[] findFloatingItems(JComponent f) { |
|
780 |
Container desktop = f.getParent(); |
|
781 |
Component[] children = desktop.getComponents(); |
|
782 |
int i = 0; |
|
783 |
for (i = 0; i < children.length; i++) { |
|
784 |
if (children[i] == f) { |
|
785 |
break; |
|
786 |
} |
|
787 |
} |
|
788 |
// System.out.println(i); |
|
789 |
Rectangle[] floaters = new Rectangle[i]; |
|
790 |
for (i = 0; i < floaters.length; i++) { |
|
791 |
floaters[i] = children[i].getBounds(); |
|
792 |
} |
|
793 |
||
794 |
return floaters; |
|
795 |
} |
|
796 |
||
797 |
/** |
|
798 |
* This method is here to clean up problems associated |
|
799 |
* with a race condition which can occur when the full contents |
|
800 |
* of a copyArea's source argument is not available onscreen. |
|
801 |
* This uses brute force to clean up in case of possible damage |
|
802 |
*/ |
|
803 |
private void emergencyCleanup(final JComponent f) { |
|
804 |
||
805 |
if ( ((JInternalFrame)f).danger ) { |
|
806 |
||
807 |
SwingUtilities.invokeLater( new Runnable(){ |
|
808 |
public void run(){ |
|
809 |
||
810 |
((JInternalFrame)f).isDragging = false; |
|
811 |
f.paintImmediately(0,0, |
|
812 |
f.getWidth(), |
|
813 |
f.getHeight()); |
|
814 |
||
815 |
//finalFrame.repaint(); |
|
816 |
((JInternalFrame)f).isDragging = true; |
|
817 |
// System.out.println("repair complete"); |
|
818 |
}}); |
|
819 |
||
820 |
((JInternalFrame)f).danger = false; |
|
821 |
} |
|
822 |
||
823 |
} |
|
824 |
||
825 |
||
826 |
} |