2
|
1 |
/*
|
|
2 |
* Copyright 1997-2006 Sun Microsystems, Inc. All Rights Reserved.
|
|
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
|
|
7 |
* published by the Free Software Foundation. Sun designates this
|
|
8 |
* particular file as subject to the "Classpath" exception as provided
|
|
9 |
* by Sun in the LICENSE file that accompanied this code.
|
|
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 |
*
|
|
21 |
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
|
|
22 |
* CA 95054 USA or visit www.sun.com if you need additional information or
|
|
23 |
* have any questions.
|
|
24 |
*/
|
|
25 |
|
|
26 |
package javax.swing;
|
|
27 |
|
|
28 |
import java.util.List;
|
|
29 |
import java.util.ArrayList;
|
|
30 |
import java.util.Vector;
|
|
31 |
import javax.swing.plaf.*;
|
|
32 |
import javax.accessibility.*;
|
|
33 |
|
|
34 |
import java.awt.Component;
|
|
35 |
import java.awt.Container;
|
|
36 |
import java.awt.DefaultFocusTraversalPolicy;
|
|
37 |
import java.awt.FocusTraversalPolicy;
|
|
38 |
import java.awt.Window;
|
|
39 |
import java.io.ObjectOutputStream;
|
|
40 |
import java.io.ObjectInputStream;
|
|
41 |
import java.io.IOException;
|
|
42 |
import java.beans.PropertyVetoException;
|
|
43 |
import java.util.Set;
|
|
44 |
import java.util.TreeSet;
|
|
45 |
|
|
46 |
/**
|
|
47 |
* A container used to create a multiple-document interface or a virtual desktop.
|
|
48 |
* You create <code>JInternalFrame</code> objects and add them to the
|
|
49 |
* <code>JDesktopPane</code>. <code>JDesktopPane</code> extends
|
|
50 |
* <code>JLayeredPane</code> to manage the potentially overlapping internal
|
|
51 |
* frames. It also maintains a reference to an instance of
|
|
52 |
* <code>DesktopManager</code> that is set by the UI
|
|
53 |
* class for the current look and feel (L&F). Note that <code>JDesktopPane</code>
|
|
54 |
* does not support borders.
|
|
55 |
* <p>
|
|
56 |
* This class is normally used as the parent of <code>JInternalFrames</code>
|
|
57 |
* to provide a pluggable <code>DesktopManager</code> object to the
|
|
58 |
* <code>JInternalFrames</code>. The <code>installUI</code> of the
|
|
59 |
* L&F specific implementation is responsible for setting the
|
|
60 |
* <code>desktopManager</code> variable appropriately.
|
|
61 |
* When the parent of a <code>JInternalFrame</code> is a <code>JDesktopPane</code>,
|
|
62 |
* it should delegate most of its behavior to the <code>desktopManager</code>
|
|
63 |
* (closing, resizing, etc).
|
|
64 |
* <p>
|
|
65 |
* For further documentation and examples see
|
|
66 |
* <a href="http://java.sun.com/docs/books/tutorial/uiswing/components/internalframe.html">How to Use Internal Frames</a>,
|
|
67 |
* a section in <em>The Java Tutorial</em>.
|
|
68 |
* <p>
|
|
69 |
* <strong>Warning:</strong> Swing is not thread safe. For more
|
|
70 |
* information see <a
|
|
71 |
* href="package-summary.html#threading">Swing's Threading
|
|
72 |
* Policy</a>.
|
|
73 |
* <p>
|
|
74 |
* <strong>Warning:</strong>
|
|
75 |
* Serialized objects of this class will not be compatible with
|
|
76 |
* future Swing releases. The current serialization support is
|
|
77 |
* appropriate for short term storage or RMI between applications running
|
|
78 |
* the same version of Swing. As of 1.4, support for long term storage
|
|
79 |
* of all JavaBeans<sup><font size="-2">TM</font></sup>
|
|
80 |
* has been added to the <code>java.beans</code> package.
|
|
81 |
* Please see {@link java.beans.XMLEncoder}.
|
|
82 |
*
|
|
83 |
* @see JInternalFrame
|
|
84 |
* @see JInternalFrame.JDesktopIcon
|
|
85 |
* @see DesktopManager
|
|
86 |
*
|
|
87 |
* @author David Kloba
|
|
88 |
*/
|
|
89 |
public class JDesktopPane extends JLayeredPane implements Accessible
|
|
90 |
{
|
|
91 |
/**
|
|
92 |
* @see #getUIClassID
|
|
93 |
* @see #readObject
|
|
94 |
*/
|
|
95 |
private static final String uiClassID = "DesktopPaneUI";
|
|
96 |
|
|
97 |
transient DesktopManager desktopManager;
|
|
98 |
|
|
99 |
private transient JInternalFrame selectedFrame = null;
|
|
100 |
|
|
101 |
/**
|
|
102 |
* Indicates that the entire contents of the item being dragged
|
|
103 |
* should appear inside the desktop pane.
|
|
104 |
*
|
|
105 |
* @see #OUTLINE_DRAG_MODE
|
|
106 |
* @see #setDragMode
|
|
107 |
*/
|
|
108 |
public static final int LIVE_DRAG_MODE = 0;
|
|
109 |
|
|
110 |
/**
|
|
111 |
* Indicates that an outline only of the item being dragged
|
|
112 |
* should appear inside the desktop pane.
|
|
113 |
*
|
|
114 |
* @see #LIVE_DRAG_MODE
|
|
115 |
* @see #setDragMode
|
|
116 |
*/
|
|
117 |
public static final int OUTLINE_DRAG_MODE = 1;
|
|
118 |
|
|
119 |
private int dragMode = LIVE_DRAG_MODE;
|
|
120 |
private boolean dragModeSet = false;
|
|
121 |
private transient List<JInternalFrame> framesCache;
|
|
122 |
private boolean componentOrderCheckingEnabled = true;
|
|
123 |
private boolean componentOrderChanged = false;
|
|
124 |
|
|
125 |
/**
|
|
126 |
* Creates a new <code>JDesktopPane</code>.
|
|
127 |
*/
|
|
128 |
public JDesktopPane() {
|
|
129 |
setUIProperty("opaque", Boolean.TRUE);
|
|
130 |
setFocusCycleRoot(true);
|
|
131 |
|
|
132 |
setFocusTraversalPolicy(new LayoutFocusTraversalPolicy() {
|
|
133 |
public Component getDefaultComponent(Container c) {
|
|
134 |
JInternalFrame jifArray[] = getAllFrames();
|
|
135 |
Component comp = null;
|
|
136 |
for (int i = 0; i < jifArray.length; i++) {
|
|
137 |
comp = jifArray[i].getFocusTraversalPolicy().getDefaultComponent(jifArray[i]);
|
|
138 |
if (comp != null) {
|
|
139 |
break;
|
|
140 |
}
|
|
141 |
}
|
|
142 |
return comp;
|
|
143 |
}
|
|
144 |
});
|
|
145 |
updateUI();
|
|
146 |
}
|
|
147 |
|
|
148 |
/**
|
|
149 |
* Returns the L&F object that renders this component.
|
|
150 |
*
|
|
151 |
* @return the <code>DesktopPaneUI</code> object that
|
|
152 |
* renders this component
|
|
153 |
*/
|
|
154 |
public DesktopPaneUI getUI() {
|
|
155 |
return (DesktopPaneUI)ui;
|
|
156 |
}
|
|
157 |
|
|
158 |
/**
|
|
159 |
* Sets the L&F object that renders this component.
|
|
160 |
*
|
|
161 |
* @param ui the DesktopPaneUI L&F object
|
|
162 |
* @see UIDefaults#getUI
|
|
163 |
* @beaninfo
|
|
164 |
* bound: true
|
|
165 |
* hidden: true
|
|
166 |
* attribute: visualUpdate true
|
|
167 |
* description: The UI object that implements the Component's LookAndFeel.
|
|
168 |
*/
|
|
169 |
public void setUI(DesktopPaneUI ui) {
|
|
170 |
super.setUI(ui);
|
|
171 |
}
|
|
172 |
|
|
173 |
/**
|
|
174 |
* Sets the "dragging style" used by the desktop pane.
|
|
175 |
* You may want to change to one mode or another for
|
|
176 |
* performance or aesthetic reasons.
|
|
177 |
*
|
|
178 |
* @param dragMode the style of drag to use for items in the Desktop
|
|
179 |
*
|
|
180 |
* @see #LIVE_DRAG_MODE
|
|
181 |
* @see #OUTLINE_DRAG_MODE
|
|
182 |
*
|
|
183 |
* @beaninfo
|
|
184 |
* bound: true
|
|
185 |
* description: Dragging style for internal frame children.
|
|
186 |
* enum: LIVE_DRAG_MODE JDesktopPane.LIVE_DRAG_MODE
|
|
187 |
* OUTLINE_DRAG_MODE JDesktopPane.OUTLINE_DRAG_MODE
|
|
188 |
* @since 1.3
|
|
189 |
*/
|
|
190 |
public void setDragMode(int dragMode) {
|
|
191 |
int oldDragMode = this.dragMode;
|
|
192 |
this.dragMode = dragMode;
|
|
193 |
firePropertyChange("dragMode", oldDragMode, this.dragMode);
|
|
194 |
dragModeSet = true;
|
|
195 |
}
|
|
196 |
|
|
197 |
/**
|
|
198 |
* Gets the current "dragging style" used by the desktop pane.
|
|
199 |
* @return either <code>Live_DRAG_MODE</code> or
|
|
200 |
* <code>OUTLINE_DRAG_MODE</code>
|
|
201 |
* @see #setDragMode
|
|
202 |
* @since 1.3
|
|
203 |
*/
|
|
204 |
public int getDragMode() {
|
|
205 |
return dragMode;
|
|
206 |
}
|
|
207 |
|
|
208 |
/**
|
|
209 |
* Returns the <code>DesktopManger</code> that handles
|
|
210 |
* desktop-specific UI actions.
|
|
211 |
*/
|
|
212 |
public DesktopManager getDesktopManager() {
|
|
213 |
return desktopManager;
|
|
214 |
}
|
|
215 |
|
|
216 |
/**
|
|
217 |
* Sets the <code>DesktopManger</code> that will handle
|
|
218 |
* desktop-specific UI actions.
|
|
219 |
*
|
|
220 |
* @param d the <code>DesktopManager</code> to use
|
|
221 |
*
|
|
222 |
* @beaninfo
|
|
223 |
* bound: true
|
|
224 |
* description: Desktop manager to handle the internal frames in the
|
|
225 |
* desktop pane.
|
|
226 |
*/
|
|
227 |
public void setDesktopManager(DesktopManager d) {
|
|
228 |
DesktopManager oldValue = desktopManager;
|
|
229 |
desktopManager = d;
|
|
230 |
firePropertyChange("desktopManager", oldValue, desktopManager);
|
|
231 |
}
|
|
232 |
|
|
233 |
/**
|
|
234 |
* Notification from the <code>UIManager</code> that the L&F has changed.
|
|
235 |
* Replaces the current UI object with the latest version from the
|
|
236 |
* <code>UIManager</code>.
|
|
237 |
*
|
|
238 |
* @see JComponent#updateUI
|
|
239 |
*/
|
|
240 |
public void updateUI() {
|
|
241 |
setUI((DesktopPaneUI)UIManager.getUI(this));
|
|
242 |
}
|
|
243 |
|
|
244 |
|
|
245 |
/**
|
|
246 |
* Returns the name of the L&F class that renders this component.
|
|
247 |
*
|
|
248 |
* @return the string "DesktopPaneUI"
|
|
249 |
* @see JComponent#getUIClassID
|
|
250 |
* @see UIDefaults#getUI
|
|
251 |
*/
|
|
252 |
public String getUIClassID() {
|
|
253 |
return uiClassID;
|
|
254 |
}
|
|
255 |
|
|
256 |
/**
|
|
257 |
* Returns all <code>JInternalFrames</code> currently displayed in the
|
|
258 |
* desktop. Returns iconified frames as well as expanded frames.
|
|
259 |
*
|
|
260 |
* @return an array of <code>JInternalFrame</code> objects
|
|
261 |
*/
|
|
262 |
public JInternalFrame[] getAllFrames() {
|
|
263 |
int i, count;
|
|
264 |
JInternalFrame[] results;
|
|
265 |
Vector vResults = new Vector(10);
|
|
266 |
Object next, tmp;
|
|
267 |
|
|
268 |
count = getComponentCount();
|
|
269 |
for(i = 0; i < count; i++) {
|
|
270 |
next = getComponent(i);
|
|
271 |
if(next instanceof JInternalFrame)
|
|
272 |
vResults.addElement(next);
|
|
273 |
else if(next instanceof JInternalFrame.JDesktopIcon) {
|
|
274 |
tmp = ((JInternalFrame.JDesktopIcon)next).getInternalFrame();
|
|
275 |
if(tmp != null)
|
|
276 |
vResults.addElement(tmp);
|
|
277 |
}
|
|
278 |
}
|
|
279 |
|
|
280 |
results = new JInternalFrame[vResults.size()];
|
|
281 |
vResults.copyInto(results);
|
|
282 |
|
|
283 |
return results;
|
|
284 |
}
|
|
285 |
|
|
286 |
/** Returns the currently active <code>JInternalFrame</code>
|
|
287 |
* in this <code>JDesktopPane</code>, or <code>null</code>
|
|
288 |
* if no <code>JInternalFrame</code> is currently active.
|
|
289 |
*
|
|
290 |
* @return the currently active <code>JInternalFrame</code> or
|
|
291 |
* <code>null</code>
|
|
292 |
* @since 1.3
|
|
293 |
*/
|
|
294 |
|
|
295 |
public JInternalFrame getSelectedFrame() {
|
|
296 |
return selectedFrame;
|
|
297 |
}
|
|
298 |
|
|
299 |
/** Sets the currently active <code>JInternalFrame</code>
|
|
300 |
* in this <code>JDesktopPane</code>. This method is used to bridge
|
|
301 |
* the package gap between JDesktopPane and the platform implementation
|
|
302 |
* code and should not be called directly. To visually select the frame
|
|
303 |
* the client must call JInternalFrame.setSelected(true) to activate
|
|
304 |
* the frame.
|
|
305 |
* @see JInternalFrame#setSelected(boolean)
|
|
306 |
*
|
|
307 |
* @param f the internal frame that's currently selected
|
|
308 |
* @since 1.3
|
|
309 |
*/
|
|
310 |
|
|
311 |
public void setSelectedFrame(JInternalFrame f) {
|
|
312 |
selectedFrame = f;
|
|
313 |
}
|
|
314 |
|
|
315 |
/**
|
|
316 |
* Returns all <code>JInternalFrames</code> currently displayed in the
|
|
317 |
* specified layer of the desktop. Returns iconified frames as well
|
|
318 |
* expanded frames.
|
|
319 |
*
|
|
320 |
* @param layer an int specifying the desktop layer
|
|
321 |
* @return an array of <code>JInternalFrame</code> objects
|
|
322 |
* @see JLayeredPane
|
|
323 |
*/
|
|
324 |
public JInternalFrame[] getAllFramesInLayer(int layer) {
|
|
325 |
int i, count;
|
|
326 |
JInternalFrame[] results;
|
|
327 |
Vector vResults = new Vector(10);
|
|
328 |
Object next, tmp;
|
|
329 |
|
|
330 |
count = getComponentCount();
|
|
331 |
for(i = 0; i < count; i++) {
|
|
332 |
next = getComponent(i);
|
|
333 |
if(next instanceof JInternalFrame) {
|
|
334 |
if(((JInternalFrame)next).getLayer() == layer)
|
|
335 |
vResults.addElement(next);
|
|
336 |
} else if(next instanceof JInternalFrame.JDesktopIcon) {
|
|
337 |
tmp = ((JInternalFrame.JDesktopIcon)next).getInternalFrame();
|
|
338 |
if(tmp != null && ((JInternalFrame)tmp).getLayer() == layer)
|
|
339 |
vResults.addElement(tmp);
|
|
340 |
}
|
|
341 |
}
|
|
342 |
|
|
343 |
results = new JInternalFrame[vResults.size()];
|
|
344 |
vResults.copyInto(results);
|
|
345 |
|
|
346 |
return results;
|
|
347 |
}
|
|
348 |
|
|
349 |
private List<JInternalFrame> getFrames() {
|
|
350 |
Component c;
|
|
351 |
Set<ComponentPosition> set = new TreeSet<ComponentPosition>();
|
|
352 |
for (int i = 0; i < getComponentCount(); i++) {
|
|
353 |
c = getComponent(i);
|
|
354 |
if (c instanceof JInternalFrame) {
|
|
355 |
set.add(new ComponentPosition((JInternalFrame)c, getLayer(c),
|
|
356 |
i));
|
|
357 |
}
|
|
358 |
else if (c instanceof JInternalFrame.JDesktopIcon) {
|
|
359 |
c = ((JInternalFrame.JDesktopIcon)c).getInternalFrame();
|
|
360 |
set.add(new ComponentPosition((JInternalFrame)c, getLayer(c),
|
|
361 |
i));
|
|
362 |
}
|
|
363 |
}
|
|
364 |
List<JInternalFrame> frames = new ArrayList<JInternalFrame>(
|
|
365 |
set.size());
|
|
366 |
for (ComponentPosition position : set) {
|
|
367 |
frames.add(position.component);
|
|
368 |
}
|
|
369 |
return frames;
|
|
370 |
}
|
|
371 |
|
|
372 |
private static class ComponentPosition implements
|
|
373 |
Comparable<ComponentPosition> {
|
|
374 |
private final JInternalFrame component;
|
|
375 |
private final int layer;
|
|
376 |
private final int zOrder;
|
|
377 |
|
|
378 |
ComponentPosition(JInternalFrame component, int layer, int zOrder) {
|
|
379 |
this.component = component;
|
|
380 |
this.layer = layer;
|
|
381 |
this.zOrder = zOrder;
|
|
382 |
}
|
|
383 |
|
|
384 |
public int compareTo(ComponentPosition o) {
|
|
385 |
int delta = o.layer - layer;
|
|
386 |
if (delta == 0) {
|
|
387 |
return zOrder - o.zOrder;
|
|
388 |
}
|
|
389 |
return delta;
|
|
390 |
}
|
|
391 |
}
|
|
392 |
|
|
393 |
private JInternalFrame getNextFrame(JInternalFrame f, boolean forward) {
|
|
394 |
verifyFramesCache();
|
|
395 |
if (f == null) {
|
|
396 |
return getTopInternalFrame();
|
|
397 |
}
|
|
398 |
int i = framesCache.indexOf(f);
|
|
399 |
if (i == -1 || framesCache.size() == 1) {
|
|
400 |
/* error */
|
|
401 |
return null;
|
|
402 |
}
|
|
403 |
if (forward) {
|
|
404 |
// navigate to the next frame
|
|
405 |
if (++i == framesCache.size()) {
|
|
406 |
/* wrap */
|
|
407 |
i = 0;
|
|
408 |
}
|
|
409 |
}
|
|
410 |
else {
|
|
411 |
// navigate to the previous frame
|
|
412 |
if (--i == -1) {
|
|
413 |
/* wrap */
|
|
414 |
i = framesCache.size() - 1;
|
|
415 |
}
|
|
416 |
}
|
|
417 |
return framesCache.get(i);
|
|
418 |
}
|
|
419 |
|
|
420 |
JInternalFrame getNextFrame(JInternalFrame f) {
|
|
421 |
return getNextFrame(f, true);
|
|
422 |
}
|
|
423 |
|
|
424 |
private JInternalFrame getTopInternalFrame() {
|
|
425 |
if (framesCache.size() == 0) {
|
|
426 |
return null;
|
|
427 |
}
|
|
428 |
return framesCache.get(0);
|
|
429 |
}
|
|
430 |
|
|
431 |
private void updateFramesCache() {
|
|
432 |
framesCache = getFrames();
|
|
433 |
}
|
|
434 |
|
|
435 |
private void verifyFramesCache() {
|
|
436 |
// If framesCache is dirty, then recreate it.
|
|
437 |
if (componentOrderChanged) {
|
|
438 |
componentOrderChanged = false;
|
|
439 |
updateFramesCache();
|
|
440 |
}
|
|
441 |
}
|
|
442 |
|
|
443 |
/**
|
|
444 |
* Selects the next <code>JInternalFrame</code> in this desktop pane.
|
|
445 |
*
|
|
446 |
* @param forward a boolean indicating which direction to select in;
|
|
447 |
* <code>true</code> for forward, <code>false</code> for
|
|
448 |
* backward
|
|
449 |
* @return the JInternalFrame that was selected or <code>null</code>
|
|
450 |
* if nothing was selected
|
|
451 |
* @since 1.6
|
|
452 |
*/
|
|
453 |
public JInternalFrame selectFrame(boolean forward) {
|
|
454 |
JInternalFrame selectedFrame = getSelectedFrame();
|
|
455 |
JInternalFrame frameToSelect = getNextFrame(selectedFrame, forward);
|
|
456 |
if (frameToSelect == null) {
|
|
457 |
return null;
|
|
458 |
}
|
|
459 |
// Maintain navigation traversal order until an
|
|
460 |
// external stack change, such as a click on a frame.
|
|
461 |
setComponentOrderCheckingEnabled(false);
|
|
462 |
if (forward && selectedFrame != null) {
|
|
463 |
selectedFrame.moveToBack(); // For Windows MDI fidelity.
|
|
464 |
}
|
|
465 |
try { frameToSelect.setSelected(true);
|
|
466 |
} catch (PropertyVetoException pve) {}
|
|
467 |
setComponentOrderCheckingEnabled(true);
|
|
468 |
return frameToSelect;
|
|
469 |
}
|
|
470 |
|
|
471 |
/*
|
|
472 |
* Sets whether component order checking is enabled.
|
|
473 |
* @param enable a boolean value, where <code>true</code> means
|
|
474 |
* a change in component order will cause a change in the keyboard
|
|
475 |
* navigation order.
|
|
476 |
* @since 1.6
|
|
477 |
*/
|
|
478 |
void setComponentOrderCheckingEnabled(boolean enable) {
|
|
479 |
componentOrderCheckingEnabled = enable;
|
|
480 |
}
|
|
481 |
|
|
482 |
/**
|
|
483 |
* {@inheritDoc}
|
|
484 |
* @since 1.6
|
|
485 |
*/
|
|
486 |
protected void addImpl(Component comp, Object constraints, int index) {
|
|
487 |
super.addImpl(comp, constraints, index);
|
|
488 |
if (componentOrderCheckingEnabled) {
|
|
489 |
if (comp instanceof JInternalFrame ||
|
|
490 |
comp instanceof JInternalFrame.JDesktopIcon) {
|
|
491 |
componentOrderChanged = true;
|
|
492 |
}
|
|
493 |
}
|
|
494 |
}
|
|
495 |
|
|
496 |
/**
|
|
497 |
* {@inheritDoc}
|
|
498 |
* @since 1.6
|
|
499 |
*/
|
|
500 |
public void remove(int index) {
|
|
501 |
if (componentOrderCheckingEnabled) {
|
|
502 |
Component comp = getComponent(index);
|
|
503 |
if (comp instanceof JInternalFrame ||
|
|
504 |
comp instanceof JInternalFrame.JDesktopIcon) {
|
|
505 |
componentOrderChanged = true;
|
|
506 |
}
|
|
507 |
}
|
|
508 |
super.remove(index);
|
|
509 |
}
|
|
510 |
|
|
511 |
/**
|
|
512 |
* {@inheritDoc}
|
|
513 |
* @since 1.6
|
|
514 |
*/
|
|
515 |
public void removeAll() {
|
|
516 |
if (componentOrderCheckingEnabled) {
|
|
517 |
int count = getComponentCount();
|
|
518 |
for (int i = 0; i < count; i++) {
|
|
519 |
Component comp = getComponent(i);
|
|
520 |
if (comp instanceof JInternalFrame ||
|
|
521 |
comp instanceof JInternalFrame.JDesktopIcon) {
|
|
522 |
componentOrderChanged = true;
|
|
523 |
break;
|
|
524 |
}
|
|
525 |
}
|
|
526 |
}
|
|
527 |
super.removeAll();
|
|
528 |
}
|
|
529 |
|
|
530 |
/**
|
|
531 |
* {@inheritDoc}
|
|
532 |
* @since 1.6
|
|
533 |
*/
|
|
534 |
public void setComponentZOrder(Component comp, int index) {
|
|
535 |
super.setComponentZOrder(comp, index);
|
|
536 |
if (componentOrderCheckingEnabled) {
|
|
537 |
if (comp instanceof JInternalFrame ||
|
|
538 |
comp instanceof JInternalFrame.JDesktopIcon) {
|
|
539 |
componentOrderChanged = true;
|
|
540 |
}
|
|
541 |
}
|
|
542 |
}
|
|
543 |
|
|
544 |
/**
|
|
545 |
* See readObject() and writeObject() in JComponent for more
|
|
546 |
* information about serialization in Swing.
|
|
547 |
*/
|
|
548 |
private void writeObject(ObjectOutputStream s) throws IOException {
|
|
549 |
s.defaultWriteObject();
|
|
550 |
if (getUIClassID().equals(uiClassID)) {
|
|
551 |
byte count = JComponent.getWriteObjCounter(this);
|
|
552 |
JComponent.setWriteObjCounter(this, --count);
|
|
553 |
if (count == 0 && ui != null) {
|
|
554 |
ui.installUI(this);
|
|
555 |
}
|
|
556 |
}
|
|
557 |
}
|
|
558 |
|
|
559 |
void setUIProperty(String propertyName, Object value) {
|
|
560 |
if (propertyName == "dragMode") {
|
|
561 |
if (!dragModeSet) {
|
|
562 |
setDragMode(((Integer)value).intValue());
|
|
563 |
dragModeSet = false;
|
|
564 |
}
|
|
565 |
} else {
|
|
566 |
super.setUIProperty(propertyName, value);
|
|
567 |
}
|
|
568 |
}
|
|
569 |
|
|
570 |
/**
|
|
571 |
* Returns a string representation of this <code>JDesktopPane</code>.
|
|
572 |
* This method is intended to be used only for debugging purposes, and the
|
|
573 |
* content and format of the returned string may vary between
|
|
574 |
* implementations. The returned string may be empty but may not
|
|
575 |
* be <code>null</code>.
|
|
576 |
*
|
|
577 |
* @return a string representation of this <code>JDesktopPane</code>
|
|
578 |
*/
|
|
579 |
protected String paramString() {
|
|
580 |
String desktopManagerString = (desktopManager != null ?
|
|
581 |
desktopManager.toString() : "");
|
|
582 |
|
|
583 |
return super.paramString() +
|
|
584 |
",desktopManager=" + desktopManagerString;
|
|
585 |
}
|
|
586 |
|
|
587 |
/////////////////
|
|
588 |
// Accessibility support
|
|
589 |
////////////////
|
|
590 |
|
|
591 |
/**
|
|
592 |
* Gets the <code>AccessibleContext</code> associated with this
|
|
593 |
* <code>JDesktopPane</code>. For desktop panes, the
|
|
594 |
* <code>AccessibleContext</code> takes the form of an
|
|
595 |
* <code>AccessibleJDesktopPane</code>.
|
|
596 |
* A new <code>AccessibleJDesktopPane</code> instance is created if necessary.
|
|
597 |
*
|
|
598 |
* @return an <code>AccessibleJDesktopPane</code> that serves as the
|
|
599 |
* <code>AccessibleContext</code> of this <code>JDesktopPane</code>
|
|
600 |
*/
|
|
601 |
public AccessibleContext getAccessibleContext() {
|
|
602 |
if (accessibleContext == null) {
|
|
603 |
accessibleContext = new AccessibleJDesktopPane();
|
|
604 |
}
|
|
605 |
return accessibleContext;
|
|
606 |
}
|
|
607 |
|
|
608 |
/**
|
|
609 |
* This class implements accessibility support for the
|
|
610 |
* <code>JDesktopPane</code> class. It provides an implementation of the
|
|
611 |
* Java Accessibility API appropriate to desktop pane user-interface
|
|
612 |
* elements.
|
|
613 |
* <p>
|
|
614 |
* <strong>Warning:</strong>
|
|
615 |
* Serialized objects of this class will not be compatible with
|
|
616 |
* future Swing releases. The current serialization support is
|
|
617 |
* appropriate for short term storage or RMI between applications running
|
|
618 |
* the same version of Swing. As of 1.4, support for long term storage
|
|
619 |
* of all JavaBeans<sup><font size="-2">TM</font></sup>
|
|
620 |
* has been added to the <code>java.beans</code> package.
|
|
621 |
* Please see {@link java.beans.XMLEncoder}.
|
|
622 |
*/
|
|
623 |
protected class AccessibleJDesktopPane extends AccessibleJComponent {
|
|
624 |
|
|
625 |
/**
|
|
626 |
* Get the role of this object.
|
|
627 |
*
|
|
628 |
* @return an instance of AccessibleRole describing the role of the
|
|
629 |
* object
|
|
630 |
* @see AccessibleRole
|
|
631 |
*/
|
|
632 |
public AccessibleRole getAccessibleRole() {
|
|
633 |
return AccessibleRole.DESKTOP_PANE;
|
|
634 |
}
|
|
635 |
}
|
|
636 |
}
|