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
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
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) {
|
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 (JInternalFrame jif : jifArray) {
137 comp = jif.getFocusTraversalPolicy().getDefaultComponent(jif);
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
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<JInternalFrame> vResults = new Vector<JInternalFrame>(10);
266
267 count = getComponentCount();
268 for(i = 0; i < count; i++) {
269 Component next = getComponent(i);
270 if(next instanceof JInternalFrame)
271 vResults.addElement((JInternalFrame) next);
272 else if(next instanceof JInternalFrame.JDesktopIcon) {
273 JInternalFrame tmp = ((JInternalFrame.JDesktopIcon)next).getInternalFrame();
274 if(tmp != null)
275 vResults.addElement(tmp);
276 }
277 }
278
279 results = new JInternalFrame[vResults.size()];
280 vResults.copyInto(results);
281
282 return results;
283 }
284
285 /** Returns the currently active <code>JInternalFrame</code>
286 * in this <code>JDesktopPane</code>, or <code>null</code>
287 * if no <code>JInternalFrame</code> is currently active.
288 *
289 * @return the currently active <code>JInternalFrame</code> or
290 * <code>null</code>
291 * @since 1.3
292 */
293
306 * @param f the internal frame that's currently selected
307 * @since 1.3
308 */
309
310 public void setSelectedFrame(JInternalFrame f) {
311 selectedFrame = f;
312 }
313
314 /**
315 * Returns all <code>JInternalFrames</code> currently displayed in the
316 * specified layer of the desktop. Returns iconified frames as well
317 * expanded frames.
318 *
319 * @param layer an int specifying the desktop layer
320 * @return an array of <code>JInternalFrame</code> objects
321 * @see JLayeredPane
322 */
323 public JInternalFrame[] getAllFramesInLayer(int layer) {
324 int i, count;
325 JInternalFrame[] results;
326 Vector<JInternalFrame> vResults = new Vector<JInternalFrame>(10);
327
328 count = getComponentCount();
329 for(i = 0; i < count; i++) {
330 Component next = getComponent(i);
331 if(next instanceof JInternalFrame) {
332 if(((JInternalFrame)next).getLayer() == layer)
333 vResults.addElement((JInternalFrame) next);
334 } else if(next instanceof JInternalFrame.JDesktopIcon) {
335 JInternalFrame tmp = ((JInternalFrame.JDesktopIcon)next).getInternalFrame();
336 if(tmp != null && tmp.getLayer() == layer)
337 vResults.addElement(tmp);
338 }
339 }
340
341 results = new JInternalFrame[vResults.size()];
342 vResults.copyInto(results);
343
344 return results;
345 }
346
347 private List<JInternalFrame> getFrames() {
348 Component c;
349 Set<ComponentPosition> set = new TreeSet<ComponentPosition>();
350 for (int i = 0; i < getComponentCount(); i++) {
351 c = getComponent(i);
352 if (c instanceof JInternalFrame) {
353 set.add(new ComponentPosition((JInternalFrame)c, getLayer(c),
354 i));
355 }
356 else if (c instanceof JInternalFrame.JDesktopIcon) {
|