189 |
p.setSelectedFrame(frame); |
p.setSelectedFrame(frame); |
190 |
else |
else |
191 |
{ |
{ |
192 |
try |
try |
193 |
{ |
{ |
194 |
frame.setSelected(true); |
frame.setSelected(true); |
195 |
} |
} |
196 |
catch (PropertyVetoException e) |
catch (PropertyVetoException e) |
197 |
{ |
{ |
198 |
// Do nothing. |
// Do nothing. |
199 |
} |
} |
200 |
} |
} |
201 |
|
|
202 |
setBoundsForFrame(frame, normalBounds.x, normalBounds.y, |
setBoundsForFrame(frame, normalBounds.x, normalBounds.y, |
217 |
p.setSelectedFrame(null); |
p.setSelectedFrame(null); |
218 |
else |
else |
219 |
{ |
{ |
220 |
try |
try |
221 |
{ |
{ |
222 |
frame.setSelected(false); |
frame.setSelected(false); |
223 |
} |
} |
224 |
catch (PropertyVetoException e) |
catch (PropertyVetoException e) |
225 |
{ |
{ |
226 |
} |
} |
227 |
} |
} |
228 |
|
|
229 |
Container c = frame.getParent(); |
Container c = frame.getParent(); |
230 |
|
|
231 |
if (! wasIcon(frame)) |
if (!wasIcon(frame)) |
232 |
{ |
{ |
233 |
Rectangle r = getBoundsForIconOf(frame); |
Rectangle r = getBoundsForIconOf(frame); |
234 |
icon.setBounds(r); |
icon.setBounds(r); |
235 |
setWasIcon(frame, Boolean.TRUE); |
setWasIcon(frame, Boolean.TRUE); |
236 |
} |
} |
237 |
|
|
238 |
if (c != null) |
if (c != null) |
239 |
{ |
{ |
240 |
if (icon != null) |
if (icon != null) |
241 |
{ |
{ |
242 |
c.add(icon); |
c.add(icon); |
243 |
icon.setVisible(true); |
icon.setVisible(true); |
244 |
} |
} |
245 |
c.remove(frame); |
c.remove(frame); |
246 |
} |
} |
247 |
} |
} |
248 |
|
|
261 |
c.add(frame); |
c.add(frame); |
262 |
frame.setVisible(true); |
frame.setVisible(true); |
263 |
|
|
264 |
if (! frame.isSelected()) |
if (!frame.isSelected()) |
265 |
{ |
{ |
266 |
JDesktopPane p = frame.getDesktopPane(); |
JDesktopPane p = frame.getDesktopPane(); |
267 |
if (p != null) |
if (p != null) |
268 |
p.setSelectedFrame(frame); |
p.setSelectedFrame(frame); |
269 |
else |
else |
270 |
{ |
{ |
271 |
try |
try |
272 |
{ |
{ |
273 |
frame.setSelected(true); |
frame.setSelected(true); |
274 |
} |
} |
275 |
catch (PropertyVetoException e) |
catch (PropertyVetoException e) |
276 |
{ |
{ |
277 |
// Do nothing. |
// Do nothing. |
278 |
} |
} |
279 |
} |
} |
280 |
} |
} |
281 |
|
|
282 |
c.invalidate(); |
c.invalidate(); |
296 |
p.setSelectedFrame(frame); |
p.setSelectedFrame(frame); |
297 |
else |
else |
298 |
{ |
{ |
299 |
try |
try |
300 |
{ |
{ |
301 |
frame.setSelected(true); |
frame.setSelected(true); |
302 |
} |
} |
303 |
catch (PropertyVetoException e) |
catch (PropertyVetoException e) |
304 |
{ |
{ |
305 |
} |
} |
306 |
} |
} |
307 |
|
|
308 |
frame.toFront(); |
frame.toFront(); |
318 |
JDesktopPane p = frame.getDesktopPane(); |
JDesktopPane p = frame.getDesktopPane(); |
319 |
if (p != null) |
if (p != null) |
320 |
{ |
{ |
321 |
if (p.getSelectedFrame() == frame) |
if (p.getSelectedFrame() == frame) |
322 |
p.setSelectedFrame(null); |
p.setSelectedFrame(null); |
323 |
} |
} |
324 |
else |
else |
325 |
{ |
{ |
326 |
try |
try |
327 |
{ |
{ |
328 |
frame.setSelected(false); |
frame.setSelected(false); |
329 |
} |
} |
330 |
catch (PropertyVetoException e) |
catch (PropertyVetoException e) |
331 |
{ |
{ |
332 |
} |
} |
333 |
} |
} |
334 |
} |
} |
335 |
|
|
361 |
* This method is called to drag the JInternalFrame to a new location. |
* This method is called to drag the JInternalFrame to a new location. |
362 |
* |
* |
363 |
* @param component The JComponent to drag, usually a JInternalFrame. |
* @param component The JComponent to drag, usually a JInternalFrame. |
364 |
|
* |
365 |
* @param newX The new x coordinate. |
* @param newX The new x coordinate. |
366 |
* @param newY The new y coordinate. |
* @param newY The new y coordinate. |
367 |
*/ |
*/ |
369 |
{ |
{ |
370 |
if (currentDragMode == JDesktopPane.OUTLINE_DRAG_MODE) |
if (currentDragMode == JDesktopPane.OUTLINE_DRAG_MODE) |
371 |
{ |
{ |
372 |
// FIXME: Do outline drag mode painting. |
// FIXME: Do outline drag mode painting. |
373 |
} |
} |
374 |
else |
else |
375 |
{ |
{ |
376 |
Rectangle b = component.getBounds(); |
Rectangle b = component.getBounds(); |
377 |
if (component instanceof JDesktopIcon) |
if (component instanceof JDesktopIcon) |
378 |
component.setBounds(newX, newY, b.width, b.height); |
component.setBounds(newX, newY, b.width, b.height); |
379 |
else |
else |
380 |
setBoundsForFrame((JInternalFrame) component, newX, newY, b.width, |
setBoundsForFrame((JInternalFrame) component, newX, newY, b.width, |
381 |
b.height); |
b.height); |
382 |
} |
} |
383 |
} |
} |
384 |
|
|
392 |
{ |
{ |
393 |
if (currentDragMode == JDesktopPane.OUTLINE_DRAG_MODE) |
if (currentDragMode == JDesktopPane.OUTLINE_DRAG_MODE) |
394 |
{ |
{ |
395 |
setBoundsForFrame((JInternalFrame) component, dragCache.x, |
setBoundsForFrame((JInternalFrame) component, dragCache.x, dragCache.y, |
396 |
dragCache.y, dragCache.width, dragCache.height); |
dragCache.width, dragCache.height); |
397 |
pane = null; |
pane = null; |
398 |
dragCache = null; |
dragCache = null; |
399 |
} |
} |
400 |
component.repaint(); |
component.repaint(); |
401 |
} |
} |
437 |
|
|
438 |
if (currentDragMode == JDesktopPane.OUTLINE_DRAG_MODE) |
if (currentDragMode == JDesktopPane.OUTLINE_DRAG_MODE) |
439 |
{ |
{ |
440 |
// FIXME: Do outline drag painting. |
// FIXME: Do outline drag painting. |
441 |
} |
} |
442 |
else |
else |
443 |
setBoundsForFrame(component, dragCache.x, dragCache.y, dragCache.width, |
setBoundsForFrame(component, dragCache.x, dragCache.y, dragCache.width, |
455 |
{ |
{ |
456 |
if (currentDragMode == JDesktopPane.OUTLINE_DRAG_MODE) |
if (currentDragMode == JDesktopPane.OUTLINE_DRAG_MODE) |
457 |
{ |
{ |
458 |
setBoundsForFrame((JInternalFrame) component, dragCache.x, |
setBoundsForFrame((JInternalFrame) component, dragCache.x, dragCache.y, |
459 |
dragCache.y, dragCache.width, dragCache.height); |
dragCache.width, dragCache.height); |
460 |
pane = null; |
pane = null; |
461 |
dragCache = null; |
dragCache = null; |
462 |
} |
} |
463 |
component.repaint(); |
component.repaint(); |
464 |
} |
} |
535 |
iconRects = new Rectangle[count]; |
iconRects = new Rectangle[count]; |
536 |
for (int i = 0, j = 0; i < frames.length; i++) |
for (int i = 0, j = 0; i < frames.length; i++) |
537 |
if (frames[i] instanceof JDesktopIcon) |
if (frames[i] instanceof JDesktopIcon) |
538 |
iconRects[--count] = frames[i].getBounds(); |
iconRects[--count] = frames[i].getBounds(); |
539 |
else if (frames[i] instanceof JInternalFrame |
else if (frames[i] instanceof JInternalFrame |
540 |
&& ((JInternalFrame) frames[i]).getWasIcon() |
&& ((JInternalFrame) frames[i]).getWasIcon() |
541 |
&& frames[i] != frame) |
&& frames[i] != frame) |
542 |
iconRects[--count] = ((JInternalFrame) frames[i]).getDesktopIcon() |
iconRects[--count] = ((JInternalFrame) frames[i]) |
543 |
.getBounds(); |
.getDesktopIcon().getBounds(); |
544 |
|
|
545 |
int startingX = insets.left; |
int startingX = insets.left; |
546 |
int startingY = paneBounds.height - insets.bottom - pref.height; |
int startingY = paneBounds.height - insets.bottom - pref.height; |
550 |
|
|
551 |
while (iconRects.length > 0) |
while (iconRects.length > 0) |
552 |
{ |
{ |
553 |
clear = true; |
clear = true; |
554 |
for (int i = 0; i < iconRects.length; i++) |
for (int i = 0; i < iconRects.length; i++) |
555 |
{ |
{ |
556 |
if (iconRects[i] != null && iconRects[i].intersects(ideal)) |
if (iconRects[i] != null && iconRects[i].intersects(ideal)) |
557 |
{ |
{ |
558 |
clear = false; |
clear = false; |
559 |
break; |
break; |
560 |
} |
} |
561 |
} |
} |
562 |
if (clear) |
if (clear) |
563 |
return ideal; |
return ideal; |
564 |
|
|
565 |
startingX += pref.width; |
startingX += pref.width; |
566 |
if (startingX + pref.width > paneBounds.width - insets.right) |
if (startingX + pref.width > paneBounds.width - insets.right) |
567 |
{ |
{ |
568 |
startingX = insets.left; |
startingX = insets.left; |
569 |
startingY -= pref.height; |
startingY -= pref.height; |
570 |
} |
} |
571 |
ideal.setBounds(startingX, startingY, pref.width, pref.height); |
ideal.setBounds(startingX, startingY, pref.width, pref.height); |
572 |
} |
} |
573 |
|
|
574 |
return ideal; |
return ideal; |