Print this page
Split |
Close |
Expand all |
Collapse all |
--- old/src/share/classes/javax/swing/JInternalFrame.java
+++ new/src/share/classes/javax/swing/JInternalFrame.java
1 1 /*
2 2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
3 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 4 *
5 5 * This code is free software; you can redistribute it and/or modify it
6 6 * under the terms of the GNU General Public License version 2 only, as
7 7 * published by the Free Software Foundation. Oracle designates this
8 8 * particular file as subject to the "Classpath" exception as provided
9 9 * by Oracle in the LICENSE file that accompanied this code.
10 10 *
11 11 * This code is distributed in the hope that it will be useful, but WITHOUT
12 12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13 13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14 14 * version 2 for more details (a copy is included in the LICENSE file that
15 15 * accompanied this code).
16 16 *
17 17 * You should have received a copy of the GNU General Public License version
18 18 * 2 along with this work; if not, write to the Free Software Foundation,
19 19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20 20 *
21 21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22 22 * or visit www.oracle.com if you need additional information or have any
23 23 * questions.
24 24 */
25 25
26 26 package javax.swing;
27 27
28 28 import java.awt.*;
29 29
30 30 import java.beans.PropertyVetoException;
31 31 import java.beans.PropertyChangeEvent;
32 32
33 33 import javax.swing.event.InternalFrameEvent;
34 34 import javax.swing.event.InternalFrameListener;
35 35 import javax.swing.plaf.*;
36 36
37 37 import javax.accessibility.*;
38 38
39 39 import java.io.ObjectOutputStream;
40 40 import java.io.IOException;
41 41 import java.lang.StringBuilder;
42 42 import java.beans.PropertyChangeListener;
↓ open down ↓ |
42 lines elided |
↑ open up ↑ |
43 43 import sun.awt.AppContext;
44 44 import sun.swing.SwingUtilities2;
45 45
46 46
47 47 /**
48 48 * A lightweight object that provides many of the features of
49 49 * a native frame, including dragging, closing, becoming an icon,
50 50 * resizing, title display, and support for a menu bar.
51 51 * For task-oriented documentation and examples of using internal frames,
52 52 * see <a
53 - href="http://docs.oracle.com/javase/tutorial/uiswing/components/internalframe.html" target="_top">How to Use Internal Frames</a>,
53 + href="https://docs.oracle.com/javase/tutorial/uiswing/components/internalframe.html" target="_top">How to Use Internal Frames</a>,
54 54 * a section in <em>The Java Tutorial</em>.
55 55 *
56 56 * <p>
57 57 *
58 58 * Generally,
59 59 * you add <code>JInternalFrame</code>s to a <code>JDesktopPane</code>. The UI
60 60 * delegates the look-and-feel-specific actions to the
61 61 * <code>DesktopManager</code>
62 62 * object maintained by the <code>JDesktopPane</code>.
63 63 * <p>
64 64 * The <code>JInternalFrame</code> content pane
65 65 * is where you add child components.
66 66 * As a convenience, the {@code add}, {@code remove}, and {@code setLayout}
67 67 * methods of this class are overridden, so that they delegate calls
68 68 * to the corresponding methods of the {@code ContentPane}.
69 69 * For example, you can add a child component to an internal frame as follows:
70 70 * <pre>
71 71 * internalFrame.add(child);
72 72 * </pre>
73 73 * And the child will be added to the contentPane.
74 74 * The content pane is actually managed by an instance of
75 75 * <code>JRootPane</code>,
76 76 * which also manages a layout pane, glass pane, and
77 77 * optional menu bar for the internal frame. Please see the
78 78 * <code>JRootPane</code>
79 79 * documentation for a complete description of these components.
80 80 * Refer to {@link javax.swing.RootPaneContainer}
81 81 * for details on adding, removing and setting the <code>LayoutManager</code>
82 82 * of a <code>JInternalFrame</code>.
83 83 * <p>
84 84 * <strong>Warning:</strong> Swing is not thread safe. For more
85 85 * information see <a
86 86 * href="package-summary.html#threading">Swing's Threading
87 87 * Policy</a>.
88 88 * <p>
89 89 * <strong>Warning:</strong>
90 90 * Serialized objects of this class will not be compatible with
91 91 * future Swing releases. The current serialization support is
92 92 * appropriate for short term storage or RMI between applications running
93 93 * the same version of Swing. As of 1.4, support for long term storage
94 94 * of all JavaBeans™
95 95 * has been added to the <code>java.beans</code> package.
96 96 * Please see {@link java.beans.XMLEncoder}.
97 97 *
98 98 * @see InternalFrameEvent
99 99 * @see JDesktopPane
100 100 * @see DesktopManager
101 101 * @see JInternalFrame.JDesktopIcon
102 102 * @see JRootPane
103 103 * @see javax.swing.RootPaneContainer
104 104 *
105 105 * @author David Kloba
106 106 * @author Rich Schiavi
107 107 * @beaninfo
108 108 * attribute: isContainer true
109 109 * attribute: containerDelegate getContentPane
110 110 * description: A frame container which is contained within
111 111 * another window.
112 112 */
113 113 public class JInternalFrame extends JComponent implements
114 114 Accessible, WindowConstants,
115 115 RootPaneContainer
116 116 {
117 117 /**
118 118 * @see #getUIClassID
119 119 * @see #readObject
120 120 */
121 121 private static final String uiClassID = "InternalFrameUI";
122 122
123 123 /**
124 124 * The <code>JRootPane</code> instance that manages the
125 125 * content pane
126 126 * and optional menu bar for this internal frame, as well as the
127 127 * glass pane.
128 128 *
129 129 * @see JRootPane
130 130 * @see RootPaneContainer
131 131 */
132 132 protected JRootPane rootPane;
133 133
134 134 /**
135 135 * If true then calls to <code>add</code> and <code>setLayout</code>
136 136 * will be forwarded to the <code>contentPane</code>. This is initially
137 137 * false, but is set to true when the <code>JInternalFrame</code> is
138 138 * constructed.
139 139 *
140 140 * @see #isRootPaneCheckingEnabled
141 141 * @see #setRootPaneCheckingEnabled
142 142 * @see javax.swing.RootPaneContainer
143 143 */
144 144 protected boolean rootPaneCheckingEnabled = false;
145 145
146 146 /** The frame can be closed. */
147 147 protected boolean closable;
148 148 /** The frame has been closed. */
149 149 protected boolean isClosed;
150 150 /** The frame can be expanded to the size of the desktop pane. */
151 151 protected boolean maximizable;
152 152 /**
153 153 * The frame has been expanded to its maximum size.
154 154 * @see #maximizable
155 155 */
156 156 protected boolean isMaximum;
157 157 /**
158 158 * The frame can "iconified" (shrunk down and displayed as
159 159 * an icon-image).
160 160 * @see JInternalFrame.JDesktopIcon
161 161 * @see #setIconifiable
162 162 */
163 163 protected boolean iconable;
164 164 /**
165 165 * The frame has been iconified.
166 166 * @see #isIcon()
167 167 */
168 168 protected boolean isIcon;
169 169 /** The frame's size can be changed. */
170 170 protected boolean resizable;
171 171 /** The frame is currently selected. */
172 172 protected boolean isSelected;
173 173 /** The icon shown in the top-left corner of this internal frame. */
174 174 protected Icon frameIcon;
175 175 /** The title displayed in this internal frame's title bar. */
176 176 protected String title;
177 177 /**
178 178 * The icon that is displayed when this internal frame is iconified.
179 179 * @see #iconable
180 180 */
181 181 protected JDesktopIcon desktopIcon;
182 182
183 183 private Cursor lastCursor;
184 184
185 185 private boolean opened;
186 186
187 187 private Rectangle normalBounds = null;
188 188
189 189 private int defaultCloseOperation = DISPOSE_ON_CLOSE;
190 190
191 191 /**
192 192 * Contains the Component that focus is to go when
193 193 * <code>restoreSubcomponentFocus</code> is invoked, that is,
194 194 * <code>restoreSubcomponentFocus</code> sets this to the value returned
195 195 * from <code>getMostRecentFocusOwner</code>.
196 196 */
197 197 private Component lastFocusOwner;
198 198
199 199 /** Bound property name. */
200 200 public final static String CONTENT_PANE_PROPERTY = "contentPane";
201 201 /** Bound property name. */
202 202 public final static String MENU_BAR_PROPERTY = "JMenuBar";
203 203 /** Bound property name. */
204 204 public final static String TITLE_PROPERTY = "title";
205 205 /** Bound property name. */
206 206 public final static String LAYERED_PANE_PROPERTY = "layeredPane";
207 207 /** Bound property name. */
208 208 public final static String ROOT_PANE_PROPERTY = "rootPane";
209 209 /** Bound property name. */
210 210 public final static String GLASS_PANE_PROPERTY = "glassPane";
211 211 /** Bound property name. */
212 212 public final static String FRAME_ICON_PROPERTY = "frameIcon";
213 213
214 214 /**
215 215 * Constrained property name indicated that this frame has
216 216 * selected status.
217 217 */
218 218 public final static String IS_SELECTED_PROPERTY = "selected";
219 219 /** Constrained property name indicating that the internal frame is closed. */
220 220 public final static String IS_CLOSED_PROPERTY = "closed";
221 221 /** Constrained property name indicating that the internal frame is maximized. */
222 222 public final static String IS_MAXIMUM_PROPERTY = "maximum";
223 223 /** Constrained property name indicating that the internal frame is iconified. */
224 224 public final static String IS_ICON_PROPERTY = "icon";
225 225
226 226 private static final Object PROPERTY_CHANGE_LISTENER_KEY =
227 227 new StringBuilder("InternalFramePropertyChangeListener");
228 228
229 229 private static void addPropertyChangeListenerIfNecessary() {
230 230 if (AppContext.getAppContext().get(PROPERTY_CHANGE_LISTENER_KEY) ==
231 231 null) {
232 232 PropertyChangeListener focusListener =
233 233 new FocusPropertyChangeListener();
234 234
235 235 AppContext.getAppContext().put(PROPERTY_CHANGE_LISTENER_KEY,
236 236 focusListener);
237 237
238 238 KeyboardFocusManager.getCurrentKeyboardFocusManager().
239 239 addPropertyChangeListener(focusListener);
240 240 }
241 241 }
242 242
243 243 private static class FocusPropertyChangeListener implements
244 244 PropertyChangeListener {
245 245 public void propertyChange(PropertyChangeEvent e) {
246 246 if (e.getPropertyName() == "permanentFocusOwner") {
247 247 updateLastFocusOwner((Component)e.getNewValue());
248 248 }
249 249 }
250 250 }
251 251
252 252 private static void updateLastFocusOwner(Component component) {
253 253 if (component != null) {
254 254 Component parent = component;
255 255 while (parent != null && !(parent instanceof Window)) {
256 256 if (parent instanceof JInternalFrame) {
257 257 // Update lastFocusOwner for parent.
258 258 ((JInternalFrame)parent).setLastFocusOwner(component);
259 259 }
260 260 parent = parent.getParent();
261 261 }
262 262 }
263 263 }
264 264
265 265 /**
266 266 * Creates a non-resizable, non-closable, non-maximizable,
267 267 * non-iconifiable <code>JInternalFrame</code> with no title.
268 268 */
269 269 public JInternalFrame() {
270 270 this("", false, false, false, false);
271 271 }
272 272
273 273 /**
274 274 * Creates a non-resizable, non-closable, non-maximizable,
275 275 * non-iconifiable <code>JInternalFrame</code> with the specified title.
276 276 * Note that passing in a <code>null</code> <code>title</code> results in
277 277 * unspecified behavior and possibly an exception.
278 278 *
279 279 * @param title the non-<code>null</code> <code>String</code>
280 280 * to display in the title bar
281 281 */
282 282 public JInternalFrame(String title) {
283 283 this(title, false, false, false, false);
284 284 }
285 285
286 286 /**
287 287 * Creates a non-closable, non-maximizable, non-iconifiable
288 288 * <code>JInternalFrame</code> with the specified title
289 289 * and resizability.
290 290 *
291 291 * @param title the <code>String</code> to display in the title bar
292 292 * @param resizable if <code>true</code>, the internal frame can be resized
293 293 */
294 294 public JInternalFrame(String title, boolean resizable) {
295 295 this(title, resizable, false, false, false);
296 296 }
297 297
298 298 /**
299 299 * Creates a non-maximizable, non-iconifiable <code>JInternalFrame</code>
300 300 * with the specified title, resizability, and
301 301 * closability.
302 302 *
303 303 * @param title the <code>String</code> to display in the title bar
304 304 * @param resizable if <code>true</code>, the internal frame can be resized
305 305 * @param closable if <code>true</code>, the internal frame can be closed
306 306 */
307 307 public JInternalFrame(String title, boolean resizable, boolean closable) {
308 308 this(title, resizable, closable, false, false);
309 309 }
310 310
311 311 /**
312 312 * Creates a non-iconifiable <code>JInternalFrame</code>
313 313 * with the specified title,
314 314 * resizability, closability, and maximizability.
315 315 *
316 316 * @param title the <code>String</code> to display in the title bar
317 317 * @param resizable if <code>true</code>, the internal frame can be resized
318 318 * @param closable if <code>true</code>, the internal frame can be closed
319 319 * @param maximizable if <code>true</code>, the internal frame can be maximized
320 320 */
321 321 public JInternalFrame(String title, boolean resizable, boolean closable,
322 322 boolean maximizable) {
323 323 this(title, resizable, closable, maximizable, false);
324 324 }
325 325
326 326 /**
327 327 * Creates a <code>JInternalFrame</code> with the specified title,
328 328 * resizability, closability, maximizability, and iconifiability.
329 329 * All <code>JInternalFrame</code> constructors use this one.
330 330 *
331 331 * @param title the <code>String</code> to display in the title bar
332 332 * @param resizable if <code>true</code>, the internal frame can be resized
333 333 * @param closable if <code>true</code>, the internal frame can be closed
334 334 * @param maximizable if <code>true</code>, the internal frame can be maximized
335 335 * @param iconifiable if <code>true</code>, the internal frame can be iconified
336 336 */
337 337 public JInternalFrame(String title, boolean resizable, boolean closable,
338 338 boolean maximizable, boolean iconifiable) {
339 339
340 340 setRootPane(createRootPane());
341 341 setLayout(new BorderLayout());
342 342 this.title = title;
343 343 this.resizable = resizable;
344 344 this.closable = closable;
345 345 this.maximizable = maximizable;
346 346 isMaximum = false;
347 347 this.iconable = iconifiable;
348 348 isIcon = false;
349 349 setVisible(false);
350 350 setRootPaneCheckingEnabled(true);
351 351 desktopIcon = new JDesktopIcon(this);
352 352 updateUI();
353 353 sun.awt.SunToolkit.checkAndSetPolicy(this);
354 354 addPropertyChangeListenerIfNecessary();
355 355 }
356 356
357 357 /**
358 358 * Called by the constructor to set up the <code>JRootPane</code>.
359 359 * @return a new <code>JRootPane</code>
360 360 * @see JRootPane
361 361 */
362 362 protected JRootPane createRootPane() {
363 363 return new JRootPane();
364 364 }
365 365
366 366 /**
367 367 * Returns the look-and-feel object that renders this component.
368 368 *
369 369 * @return the <code>InternalFrameUI</code> object that renders
370 370 * this component
371 371 */
372 372 public InternalFrameUI getUI() {
373 373 return (InternalFrameUI)ui;
374 374 }
375 375
376 376 /**
377 377 * Sets the UI delegate for this <code>JInternalFrame</code>.
378 378 * @param ui the UI delegate
379 379 * @beaninfo
380 380 * bound: true
381 381 * hidden: true
382 382 * attribute: visualUpdate true
383 383 * description: The UI object that implements the Component's LookAndFeel.
384 384 */
385 385 public void setUI(InternalFrameUI ui) {
386 386 boolean checkingEnabled = isRootPaneCheckingEnabled();
387 387 try {
388 388 setRootPaneCheckingEnabled(false);
389 389 super.setUI(ui);
390 390 }
391 391 finally {
392 392 setRootPaneCheckingEnabled(checkingEnabled);
393 393 }
394 394 }
395 395
396 396 /**
397 397 * Notification from the <code>UIManager</code> that the look and feel
398 398 * has changed.
399 399 * Replaces the current UI object with the latest version from the
400 400 * <code>UIManager</code>.
401 401 *
402 402 * @see JComponent#updateUI
403 403 */
404 404 public void updateUI() {
405 405 setUI((InternalFrameUI)UIManager.getUI(this));
406 406 invalidate();
407 407 if (desktopIcon != null) {
408 408 desktopIcon.updateUIWhenHidden();
409 409 }
410 410 }
411 411
412 412 /* This method is called if <code>updateUI</code> was called
413 413 * on the associated
414 414 * JDesktopIcon. It's necessary to avoid infinite recursion.
415 415 */
416 416 void updateUIWhenHidden() {
417 417 setUI((InternalFrameUI)UIManager.getUI(this));
418 418 invalidate();
419 419 Component[] children = getComponents();
420 420 if (children != null) {
421 421 for (Component child : children) {
422 422 SwingUtilities.updateComponentTreeUI(child);
423 423 }
424 424 }
425 425 }
426 426
427 427
428 428 /**
429 429 * Returns the name of the look-and-feel
430 430 * class that renders this component.
431 431 *
432 432 * @return the string "InternalFrameUI"
433 433 *
434 434 * @see JComponent#getUIClassID
435 435 * @see UIDefaults#getUI
436 436 *
437 437 * @beaninfo
438 438 * description: UIClassID
439 439 */
440 440 public String getUIClassID() {
441 441 return uiClassID;
442 442 }
443 443
444 444 /**
445 445 * Returns whether calls to <code>add</code> and
446 446 * <code>setLayout</code> are forwarded to the <code>contentPane</code>.
447 447 *
448 448 * @return true if <code>add</code> and <code>setLayout</code>
449 449 * are forwarded; false otherwise
450 450 *
451 451 * @see #addImpl
452 452 * @see #setLayout
453 453 * @see #setRootPaneCheckingEnabled
454 454 * @see javax.swing.RootPaneContainer
455 455 */
456 456 protected boolean isRootPaneCheckingEnabled() {
457 457 return rootPaneCheckingEnabled;
458 458 }
459 459
460 460 /**
461 461 * Sets whether calls to <code>add</code> and
462 462 * <code>setLayout</code> are forwarded to the <code>contentPane</code>.
463 463 *
464 464 * @param enabled true if <code>add</code> and <code>setLayout</code>
465 465 * are forwarded, false if they should operate directly on the
466 466 * <code>JInternalFrame</code>.
467 467 *
468 468 * @see #addImpl
469 469 * @see #setLayout
470 470 * @see #isRootPaneCheckingEnabled
471 471 * @see javax.swing.RootPaneContainer
472 472 * @beaninfo
473 473 * hidden: true
474 474 * description: Whether the add and setLayout methods are forwarded
475 475 */
476 476 protected void setRootPaneCheckingEnabled(boolean enabled) {
477 477 rootPaneCheckingEnabled = enabled;
478 478 }
479 479
480 480 /**
481 481 * Adds the specified child <code>Component</code>.
482 482 * This method is overridden to conditionally forward calls to the
483 483 * <code>contentPane</code>.
484 484 * By default, children are added to the <code>contentPane</code> instead
485 485 * of the frame, refer to {@link javax.swing.RootPaneContainer} for
486 486 * details.
487 487 *
488 488 * @param comp the component to be enhanced
489 489 * @param constraints the constraints to be respected
490 490 * @param index the index
491 491 * @exception IllegalArgumentException if <code>index</code> is invalid
492 492 * @exception IllegalArgumentException if adding the container's parent
493 493 * to itself
494 494 * @exception IllegalArgumentException if adding a window to a container
495 495 *
496 496 * @see #setRootPaneCheckingEnabled
497 497 * @see javax.swing.RootPaneContainer
498 498 */
499 499 protected void addImpl(Component comp, Object constraints, int index) {
500 500 if(isRootPaneCheckingEnabled()) {
501 501 getContentPane().add(comp, constraints, index);
502 502 }
503 503 else {
504 504 super.addImpl(comp, constraints, index);
505 505 }
506 506 }
507 507
508 508 /**
509 509 * Removes the specified component from the container. If
510 510 * <code>comp</code> is not a child of the <code>JInternalFrame</code>
511 511 * this will forward the call to the <code>contentPane</code>.
512 512 *
513 513 * @param comp the component to be removed
514 514 * @throws NullPointerException if <code>comp</code> is null
515 515 * @see #add
516 516 * @see javax.swing.RootPaneContainer
517 517 */
518 518 public void remove(Component comp) {
519 519 int oldCount = getComponentCount();
520 520 super.remove(comp);
521 521 if (oldCount == getComponentCount()) {
522 522 getContentPane().remove(comp);
523 523 }
524 524 }
525 525
526 526
527 527 /**
528 528 * Ensures that, by default, the layout of this component cannot be set.
529 529 * Overridden to conditionally forward the call to the
530 530 * <code>contentPane</code>.
531 531 * Refer to {@link javax.swing.RootPaneContainer} for
532 532 * more information.
533 533 *
534 534 * @param manager the <code>LayoutManager</code>
535 535 * @see #setRootPaneCheckingEnabled
536 536 */
537 537 public void setLayout(LayoutManager manager) {
538 538 if(isRootPaneCheckingEnabled()) {
539 539 getContentPane().setLayout(manager);
540 540 }
541 541 else {
542 542 super.setLayout(manager);
543 543 }
544 544 }
545 545
546 546
547 547 //////////////////////////////////////////////////////////////////////////
548 548 /// Property Methods
549 549 //////////////////////////////////////////////////////////////////////////
550 550
551 551 /**
552 552 * Returns the current <code>JMenuBar</code> for this
553 553 * <code>JInternalFrame</code>, or <code>null</code>
554 554 * if no menu bar has been set.
555 555 * @return the current menu bar, or <code>null</code> if none has been set
556 556 *
557 557 * @deprecated As of Swing version 1.0.3,
558 558 * replaced by <code>getJMenuBar()</code>.
559 559 */
560 560 @Deprecated
561 561 public JMenuBar getMenuBar() {
562 562 return getRootPane().getMenuBar();
563 563 }
564 564
565 565 /**
566 566 * Returns the current <code>JMenuBar</code> for this
567 567 * <code>JInternalFrame</code>, or <code>null</code>
568 568 * if no menu bar has been set.
569 569 *
570 570 * @return the <code>JMenuBar</code> used by this internal frame
571 571 * @see #setJMenuBar
572 572 */
573 573 public JMenuBar getJMenuBar() {
574 574 return getRootPane().getJMenuBar();
575 575 }
576 576
577 577 /**
578 578 * Sets the <code>menuBar</code> property for this <code>JInternalFrame</code>.
579 579 *
580 580 * @param m the <code>JMenuBar</code> to use in this internal frame
581 581 * @see #getJMenuBar
582 582 * @deprecated As of Swing version 1.0.3
583 583 * replaced by <code>setJMenuBar(JMenuBar m)</code>.
584 584 */
585 585 @Deprecated
586 586 public void setMenuBar(JMenuBar m) {
587 587 JMenuBar oldValue = getMenuBar();
588 588 getRootPane().setJMenuBar(m);
589 589 firePropertyChange(MENU_BAR_PROPERTY, oldValue, m);
590 590 }
591 591
592 592 /**
593 593 * Sets the <code>menuBar</code> property for this <code>JInternalFrame</code>.
594 594 *
595 595 * @param m the <code>JMenuBar</code> to use in this internal frame
596 596 * @see #getJMenuBar
597 597 * @beaninfo
598 598 * bound: true
599 599 * preferred: true
600 600 * description: The menu bar for accessing pulldown menus
601 601 * from this internal frame.
602 602 */
603 603 public void setJMenuBar(JMenuBar m){
604 604 JMenuBar oldValue = getMenuBar();
605 605 getRootPane().setJMenuBar(m);
606 606 firePropertyChange(MENU_BAR_PROPERTY, oldValue, m);
607 607 }
608 608
609 609 // implements javax.swing.RootPaneContainer
610 610 /**
611 611 * Returns the content pane for this internal frame.
612 612 * @return the content pane
613 613 */
614 614 public Container getContentPane() {
615 615 return getRootPane().getContentPane();
616 616 }
617 617
618 618
619 619 /**
620 620 * Sets this <code>JInternalFrame</code>'s <code>contentPane</code>
621 621 * property.
622 622 *
623 623 * @param c the content pane for this internal frame
624 624 *
625 625 * @exception java.awt.IllegalComponentStateException (a runtime
626 626 * exception) if the content pane parameter is <code>null</code>
627 627 * @see RootPaneContainer#getContentPane
628 628 * @beaninfo
629 629 * bound: true
630 630 * hidden: true
631 631 * description: The client area of the internal frame where child
632 632 * components are normally inserted.
633 633 */
634 634 public void setContentPane(Container c) {
635 635 Container oldValue = getContentPane();
636 636 getRootPane().setContentPane(c);
637 637 firePropertyChange(CONTENT_PANE_PROPERTY, oldValue, c);
638 638 }
639 639
640 640 /**
641 641 * Returns the layered pane for this internal frame.
642 642 *
643 643 * @return a <code>JLayeredPane</code> object
644 644 * @see RootPaneContainer#setLayeredPane
645 645 * @see RootPaneContainer#getLayeredPane
646 646 */
647 647 public JLayeredPane getLayeredPane() {
648 648 return getRootPane().getLayeredPane();
649 649 }
650 650
651 651 /**
652 652 * Sets this <code>JInternalFrame</code>'s
653 653 * <code>layeredPane</code> property.
654 654 *
655 655 * @param layered the <code>JLayeredPane</code> for this internal frame
656 656 *
657 657 * @exception java.awt.IllegalComponentStateException (a runtime
658 658 * exception) if the layered pane parameter is <code>null</code>
659 659 * @see RootPaneContainer#setLayeredPane
660 660 * @beaninfo
661 661 * hidden: true
662 662 * bound: true
663 663 * description: The pane which holds the various desktop layers.
664 664 */
665 665 public void setLayeredPane(JLayeredPane layered) {
666 666 JLayeredPane oldValue = getLayeredPane();
667 667 getRootPane().setLayeredPane(layered);
668 668 firePropertyChange(LAYERED_PANE_PROPERTY, oldValue, layered);
669 669 }
670 670
671 671 /**
672 672 * Returns the glass pane for this internal frame.
673 673 *
674 674 * @return the glass pane
675 675 * @see RootPaneContainer#setGlassPane
676 676 */
677 677 public Component getGlassPane() {
678 678 return getRootPane().getGlassPane();
679 679 }
680 680
681 681 /**
682 682 * Sets this <code>JInternalFrame</code>'s
683 683 * <code>glassPane</code> property.
684 684 *
685 685 * @param glass the glass pane for this internal frame
686 686 * @see RootPaneContainer#getGlassPane
687 687 * @beaninfo
688 688 * bound: true
689 689 * hidden: true
690 690 * description: A transparent pane used for menu rendering.
691 691 */
692 692 public void setGlassPane(Component glass) {
693 693 Component oldValue = getGlassPane();
694 694 getRootPane().setGlassPane(glass);
695 695 firePropertyChange(GLASS_PANE_PROPERTY, oldValue, glass);
696 696 }
697 697
698 698 /**
699 699 * Returns the <code>rootPane</code> object for this internal frame.
700 700 *
701 701 * @return the <code>rootPane</code> property
702 702 * @see RootPaneContainer#getRootPane
703 703 */
704 704 public JRootPane getRootPane() {
705 705 return rootPane;
706 706 }
707 707
708 708
709 709 /**
710 710 * Sets the <code>rootPane</code> property
711 711 * for this <code>JInternalFrame</code>.
712 712 * This method is called by the constructor.
713 713 *
714 714 * @param root the new <code>JRootPane</code> object
715 715 * @beaninfo
716 716 * bound: true
717 717 * hidden: true
718 718 * description: The root pane used by this internal frame.
719 719 */
720 720 protected void setRootPane(JRootPane root) {
721 721 if(rootPane != null) {
722 722 remove(rootPane);
723 723 }
724 724 JRootPane oldValue = getRootPane();
725 725 rootPane = root;
726 726 if(rootPane != null) {
727 727 boolean checkingEnabled = isRootPaneCheckingEnabled();
728 728 try {
729 729 setRootPaneCheckingEnabled(false);
730 730 add(rootPane, BorderLayout.CENTER);
731 731 }
732 732 finally {
733 733 setRootPaneCheckingEnabled(checkingEnabled);
734 734 }
735 735 }
736 736 firePropertyChange(ROOT_PANE_PROPERTY, oldValue, root);
737 737 }
738 738
739 739 /**
740 740 * Sets whether this <code>JInternalFrame</code> can be closed by
741 741 * some user action.
742 742 * @param b a boolean value, where <code>true</code> means this internal frame can be closed
743 743 * @beaninfo
744 744 * preferred: true
745 745 * bound: true
746 746 * description: Indicates whether this internal frame can be closed.
747 747 */
748 748 public void setClosable(boolean b) {
749 749 Boolean oldValue = closable ? Boolean.TRUE : Boolean.FALSE;
750 750 Boolean newValue = b ? Boolean.TRUE : Boolean.FALSE;
751 751 closable = b;
752 752 firePropertyChange("closable", oldValue, newValue);
753 753 }
754 754
755 755 /**
756 756 * Returns whether this <code>JInternalFrame</code> can be closed by
757 757 * some user action.
758 758 * @return <code>true</code> if this internal frame can be closed
759 759 */
760 760 public boolean isClosable() {
761 761 return closable;
762 762 }
763 763
764 764 /**
765 765 * Returns whether this <code>JInternalFrame</code> is currently closed.
766 766 * @return <code>true</code> if this internal frame is closed, <code>false</code> otherwise
767 767 */
768 768 public boolean isClosed() {
769 769 return isClosed;
770 770 }
771 771
772 772 /**
773 773 * Closes this internal frame if the argument is <code>true</code>.
774 774 * Do not invoke this method with a <code>false</code> argument;
775 775 * the result of invoking <code>setClosed(false)</code>
776 776 * is unspecified.
777 777 *
778 778 * <p>
779 779 *
780 780 * If the internal frame is already closed,
781 781 * this method does nothing and returns immediately.
782 782 * Otherwise,
783 783 * this method begins by firing
784 784 * an <code>INTERNAL_FRAME_CLOSING</code> event.
785 785 * Then this method sets the <code>closed</code> property to <code>true</code>
786 786 * unless a listener vetoes the property change.
787 787 * This method finishes by making the internal frame
788 788 * invisible and unselected,
789 789 * and then firing an <code>INTERNAL_FRAME_CLOSED</code> event.
790 790 *
791 791 * <p>
792 792 *
793 793 * <b>Note:</b>
794 794 * To reuse an internal frame that has been closed,
795 795 * you must add it to a container
796 796 * (even if you never removed it from its previous container).
797 797 * Typically, this container will be the <code>JDesktopPane</code>
798 798 * that previously contained the internal frame.
799 799 *
800 800 * @param b must be <code>true</code>
801 801 *
802 802 * @exception PropertyVetoException when the attempt to set the
803 803 * property is vetoed by the <code>JInternalFrame</code>
804 804 *
805 805 * @see #isClosed()
806 806 * @see #setDefaultCloseOperation
807 807 * @see #dispose
808 808 * @see javax.swing.event.InternalFrameEvent#INTERNAL_FRAME_CLOSING
809 809 *
810 810 * @beaninfo
811 811 * bound: true
812 812 * constrained: true
813 813 * description: Indicates whether this internal frame has been closed.
814 814 */
815 815 public void setClosed(boolean b) throws PropertyVetoException {
816 816 if (isClosed == b) {
817 817 return;
818 818 }
819 819
820 820 Boolean oldValue = isClosed ? Boolean.TRUE : Boolean.FALSE;
821 821 Boolean newValue = b ? Boolean.TRUE : Boolean.FALSE;
822 822 if (b) {
823 823 fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_CLOSING);
824 824 }
825 825 fireVetoableChange(IS_CLOSED_PROPERTY, oldValue, newValue);
826 826 isClosed = b;
827 827 if (isClosed) {
828 828 setVisible(false);
829 829 }
830 830 firePropertyChange(IS_CLOSED_PROPERTY, oldValue, newValue);
831 831 if (isClosed) {
832 832 dispose();
833 833 } else if (!opened) {
834 834 /* this bogus -- we haven't defined what
835 835 setClosed(false) means. */
836 836 // fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_OPENED);
837 837 // opened = true;
838 838 }
839 839 }
840 840
841 841 /**
842 842 * Sets whether the <code>JInternalFrame</code> can be resized by some
843 843 * user action.
844 844 *
845 845 * @param b a boolean, where <code>true</code> means this internal frame can be resized
846 846 * @beaninfo
847 847 * preferred: true
848 848 * bound: true
849 849 * description: Determines whether this internal frame can be resized
850 850 * by the user.
851 851 */
852 852 public void setResizable(boolean b) {
853 853 Boolean oldValue = resizable ? Boolean.TRUE : Boolean.FALSE;
854 854 Boolean newValue = b ? Boolean.TRUE : Boolean.FALSE;
855 855 resizable = b;
856 856 firePropertyChange("resizable", oldValue, newValue);
857 857 }
858 858
859 859 /**
860 860 * Returns whether the <code>JInternalFrame</code> can be resized
861 861 * by some user action.
862 862 *
863 863 * @return <code>true</code> if this internal frame can be resized, <code>false</code> otherwise
864 864 */
865 865 public boolean isResizable() {
866 866 // don't allow resizing when maximized.
867 867 return isMaximum ? false : resizable;
868 868 }
869 869
870 870 /**
871 871 * Sets the <code>iconable</code> property,
872 872 * which must be <code>true</code>
873 873 * for the user to be able to
874 874 * make the <code>JInternalFrame</code> an icon.
875 875 * Some look and feels might not implement iconification;
876 876 * they will ignore this property.
877 877 *
878 878 * @param b a boolean, where <code>true</code> means this internal frame can be iconified
879 879 * @beaninfo
880 880 * preferred: true
881 881 bound: true
882 882 * description: Determines whether this internal frame can be iconified.
883 883 */
884 884 public void setIconifiable(boolean b) {
885 885 Boolean oldValue = iconable ? Boolean.TRUE : Boolean.FALSE;
886 886 Boolean newValue = b ? Boolean.TRUE : Boolean.FALSE;
887 887 iconable = b;
888 888 firePropertyChange("iconable", oldValue, newValue);
889 889 }
890 890
891 891 /**
892 892 * Gets the <code>iconable</code> property,
893 893 * which by default is <code>false</code>.
894 894 *
895 895 * @return the value of the <code>iconable</code> property.
896 896 *
897 897 * @see #setIconifiable
898 898 */
899 899 public boolean isIconifiable() {
900 900 return iconable;
901 901 }
902 902
903 903 /**
904 904 * Returns whether the <code>JInternalFrame</code> is currently iconified.
905 905 *
906 906 * @return <code>true</code> if this internal frame is iconified
907 907 */
908 908 public boolean isIcon() {
909 909 return isIcon;
910 910 }
911 911
912 912 /**
913 913 * Iconifies or de-iconifies this internal frame,
914 914 * if the look and feel supports iconification.
915 915 * If the internal frame's state changes to iconified,
916 916 * this method fires an <code>INTERNAL_FRAME_ICONIFIED</code> event.
917 917 * If the state changes to de-iconified,
918 918 * an <code>INTERNAL_FRAME_DEICONIFIED</code> event is fired.
919 919 *
920 920 * @param b a boolean, where <code>true</code> means to iconify this internal frame and
921 921 * <code>false</code> means to de-iconify it
922 922 * @exception PropertyVetoException when the attempt to set the
923 923 * property is vetoed by the <code>JInternalFrame</code>
924 924 *
925 925 * @see InternalFrameEvent#INTERNAL_FRAME_ICONIFIED
926 926 * @see InternalFrameEvent#INTERNAL_FRAME_DEICONIFIED
927 927 *
928 928 * @beaninfo
929 929 * bound: true
930 930 * constrained: true
931 931 * description: The image displayed when this internal frame is minimized.
932 932 */
933 933 public void setIcon(boolean b) throws PropertyVetoException {
934 934 if (isIcon == b) {
935 935 return;
936 936 }
937 937
938 938 /* If an internal frame is being iconified before it has a
939 939 parent, (e.g., client wants it to start iconic), create the
940 940 parent if possible so that we can place the icon in its
941 941 proper place on the desktop. I am not sure the call to
942 942 validate() is necessary, since we are not going to display
943 943 this frame yet */
944 944 firePropertyChange("ancestor", null, getParent());
945 945
946 946 Boolean oldValue = isIcon ? Boolean.TRUE : Boolean.FALSE;
947 947 Boolean newValue = b ? Boolean.TRUE : Boolean.FALSE;
948 948 fireVetoableChange(IS_ICON_PROPERTY, oldValue, newValue);
949 949 isIcon = b;
950 950 firePropertyChange(IS_ICON_PROPERTY, oldValue, newValue);
951 951 if (b)
952 952 fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_ICONIFIED);
953 953 else
954 954 fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_DEICONIFIED);
955 955 }
956 956
957 957 /**
958 958 * Sets the <code>maximizable</code> property,
959 959 * which determines whether the <code>JInternalFrame</code>
960 960 * can be maximized by
961 961 * some user action.
962 962 * Some look and feels might not support maximizing internal frames;
963 963 * they will ignore this property.
964 964 *
965 965 * @param b <code>true</code> to specify that this internal frame should be maximizable; <code>false</code> to specify that it should not be
966 966 * @beaninfo
967 967 * bound: true
968 968 * preferred: true
969 969 * description: Determines whether this internal frame can be maximized.
970 970 */
971 971 public void setMaximizable(boolean b) {
972 972 Boolean oldValue = maximizable ? Boolean.TRUE : Boolean.FALSE;
973 973 Boolean newValue = b ? Boolean.TRUE : Boolean.FALSE;
974 974 maximizable = b;
975 975 firePropertyChange("maximizable", oldValue, newValue);
976 976 }
977 977
978 978 /**
979 979 * Gets the value of the <code>maximizable</code> property.
980 980 *
981 981 * @return the value of the <code>maximizable</code> property
982 982 * @see #setMaximizable
983 983 */
984 984 public boolean isMaximizable() {
985 985 return maximizable;
986 986 }
987 987
988 988 /**
989 989 * Returns whether the <code>JInternalFrame</code> is currently maximized.
990 990 *
991 991 * @return <code>true</code> if this internal frame is maximized, <code>false</code> otherwise
992 992 */
993 993 public boolean isMaximum() {
994 994 return isMaximum;
995 995 }
996 996
997 997 /**
998 998 * Maximizes and restores this internal frame. A maximized frame is resized to
999 999 * fully fit the <code>JDesktopPane</code> area associated with the
1000 1000 * <code>JInternalFrame</code>.
1001 1001 * A restored frame's size is set to the <code>JInternalFrame</code>'s
1002 1002 * actual size.
1003 1003 *
1004 1004 * @param b a boolean, where <code>true</code> maximizes this internal frame and <code>false</code>
1005 1005 * restores it
1006 1006 * @exception PropertyVetoException when the attempt to set the
1007 1007 * property is vetoed by the <code>JInternalFrame</code>
1008 1008 * @beaninfo
1009 1009 * bound: true
1010 1010 * constrained: true
1011 1011 * description: Indicates whether this internal frame is maximized.
1012 1012 */
1013 1013 public void setMaximum(boolean b) throws PropertyVetoException {
1014 1014 if (isMaximum == b) {
1015 1015 return;
1016 1016 }
1017 1017
1018 1018 Boolean oldValue = isMaximum ? Boolean.TRUE : Boolean.FALSE;
1019 1019 Boolean newValue = b ? Boolean.TRUE : Boolean.FALSE;
1020 1020 fireVetoableChange(IS_MAXIMUM_PROPERTY, oldValue, newValue);
1021 1021 /* setting isMaximum above the event firing means that
1022 1022 property listeners that, for some reason, test it will
1023 1023 get it wrong... See, for example, getNormalBounds() */
1024 1024 isMaximum = b;
1025 1025 firePropertyChange(IS_MAXIMUM_PROPERTY, oldValue, newValue);
1026 1026 }
1027 1027
1028 1028 /**
1029 1029 * Returns the title of the <code>JInternalFrame</code>.
1030 1030 *
1031 1031 * @return a <code>String</code> containing this internal frame's title
1032 1032 * @see #setTitle
1033 1033 */
1034 1034 public String getTitle() {
1035 1035 return title;
1036 1036 }
1037 1037
1038 1038 /**
1039 1039 * Sets the <code>JInternalFrame</code> title. <code>title</code>
1040 1040 * may have a <code>null</code> value.
1041 1041 * @see #getTitle
1042 1042 *
1043 1043 * @param title the <code>String</code> to display in the title bar
1044 1044 * @beaninfo
1045 1045 * preferred: true
1046 1046 * bound: true
1047 1047 * description: The text displayed in the title bar.
1048 1048 */
1049 1049 public void setTitle(String title) {
1050 1050 String oldValue = this.title;
1051 1051 this.title = title;
1052 1052 firePropertyChange(TITLE_PROPERTY, oldValue, title);
1053 1053 }
1054 1054
1055 1055 /**
1056 1056 * Selects or deselects the internal frame
1057 1057 * if it's showing.
1058 1058 * A <code>JInternalFrame</code> normally draws its title bar
1059 1059 * differently if it is
1060 1060 * the selected frame, which indicates to the user that this
1061 1061 * internal frame has the focus.
1062 1062 * When this method changes the state of the internal frame
1063 1063 * from deselected to selected, it fires an
1064 1064 * <code>InternalFrameEvent.INTERNAL_FRAME_ACTIVATED</code> event.
1065 1065 * If the change is from selected to deselected,
1066 1066 * an <code>InternalFrameEvent.INTERNAL_FRAME_DEACTIVATED</code> event
1067 1067 * is fired.
1068 1068 *
1069 1069 * @param selected a boolean, where <code>true</code> means this internal frame
1070 1070 * should become selected (currently active)
1071 1071 * and <code>false</code> means it should become deselected
1072 1072 * @exception PropertyVetoException when the attempt to set the
1073 1073 * property is vetoed by the <code>JInternalFrame</code>
1074 1074 *
1075 1075 * @see #isShowing
1076 1076 * @see InternalFrameEvent#INTERNAL_FRAME_ACTIVATED
1077 1077 * @see InternalFrameEvent#INTERNAL_FRAME_DEACTIVATED
1078 1078 *
1079 1079 * @beaninfo
1080 1080 * constrained: true
1081 1081 * bound: true
1082 1082 * description: Indicates whether this internal frame is currently
1083 1083 * the active frame.
1084 1084 */
1085 1085 public void setSelected(boolean selected) throws PropertyVetoException {
1086 1086 // The InternalFrame may already be selected, but the focus
1087 1087 // may be outside it, so restore the focus to the subcomponent
1088 1088 // which previously had it. See Bug 4302764.
1089 1089 if (selected && isSelected) {
1090 1090 restoreSubcomponentFocus();
1091 1091 return;
1092 1092 }
1093 1093 // The internal frame or the desktop icon must be showing to allow
1094 1094 // selection. We may deselect even if neither is showing.
1095 1095 if ((isSelected == selected) || (selected &&
1096 1096 (isIcon ? !desktopIcon.isShowing() : !isShowing()))) {
1097 1097 return;
1098 1098 }
1099 1099
1100 1100 Boolean oldValue = isSelected ? Boolean.TRUE : Boolean.FALSE;
1101 1101 Boolean newValue = selected ? Boolean.TRUE : Boolean.FALSE;
1102 1102 fireVetoableChange(IS_SELECTED_PROPERTY, oldValue, newValue);
1103 1103
1104 1104 /* We don't want to leave focus in the previously selected
1105 1105 frame, so we have to set it to *something* in case it
1106 1106 doesn't get set in some other way (as if a user clicked on
1107 1107 a component that doesn't request focus). If this call is
1108 1108 happening because the user clicked on a component that will
1109 1109 want focus, then it will get transfered there later.
1110 1110
1111 1111 We test for parent.isShowing() above, because AWT throws a
1112 1112 NPE if you try to request focus on a lightweight before its
1113 1113 parent has been made visible */
1114 1114
1115 1115 if (selected) {
1116 1116 restoreSubcomponentFocus();
1117 1117 }
1118 1118
1119 1119 isSelected = selected;
1120 1120 firePropertyChange(IS_SELECTED_PROPERTY, oldValue, newValue);
1121 1121 if (isSelected)
1122 1122 fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_ACTIVATED);
1123 1123 else
1124 1124 fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_DEACTIVATED);
1125 1125 repaint();
1126 1126 }
1127 1127
1128 1128 /**
1129 1129 * Returns whether the <code>JInternalFrame</code> is the
1130 1130 * currently "selected" or active frame.
1131 1131 *
1132 1132 * @return <code>true</code> if this internal frame is currently selected (active)
1133 1133 * @see #setSelected
1134 1134 */
1135 1135 public boolean isSelected() {
1136 1136 return isSelected;
1137 1137 }
1138 1138
1139 1139 /**
1140 1140 * Sets an image to be displayed in the titlebar of this internal frame (usually
1141 1141 * in the top-left corner).
1142 1142 * This image is not the <code>desktopIcon</code> object, which
1143 1143 * is the image displayed in the <code>JDesktop</code> when
1144 1144 * this internal frame is iconified.
1145 1145 *
1146 1146 * Passing <code>null</code> to this function is valid,
1147 1147 * but the look and feel
1148 1148 * can choose the
1149 1149 * appropriate behavior for that situation, such as displaying no icon
1150 1150 * or a default icon for the look and feel.
1151 1151 *
1152 1152 * @param icon the <code>Icon</code> to display in the title bar
1153 1153 * @see #getFrameIcon
1154 1154 * @beaninfo
1155 1155 * bound: true
1156 1156 * description: The icon shown in the top-left corner of this internal frame.
1157 1157 */
1158 1158 public void setFrameIcon(Icon icon) {
1159 1159 Icon oldIcon = frameIcon;
1160 1160 frameIcon = icon;
1161 1161 firePropertyChange(FRAME_ICON_PROPERTY, oldIcon, icon);
1162 1162 }
1163 1163
1164 1164 /**
1165 1165 * Returns the image displayed in the title bar of this internal frame (usually
1166 1166 * in the top-left corner).
1167 1167 *
1168 1168 * @return the <code>Icon</code> displayed in the title bar
1169 1169 * @see #setFrameIcon
1170 1170 */
1171 1171 public Icon getFrameIcon() {
1172 1172 return frameIcon;
1173 1173 }
1174 1174
1175 1175 /**
1176 1176 * Convenience method that moves this component to position 0 if its
1177 1177 * parent is a <code>JLayeredPane</code>.
1178 1178 */
1179 1179 public void moveToFront() {
1180 1180 if (isIcon()) {
1181 1181 if (getDesktopIcon().getParent() instanceof JLayeredPane) {
1182 1182 ((JLayeredPane)getDesktopIcon().getParent()).
1183 1183 moveToFront(getDesktopIcon());
1184 1184 }
1185 1185 }
1186 1186 else if (getParent() instanceof JLayeredPane) {
1187 1187 ((JLayeredPane)getParent()).moveToFront(this);
1188 1188 }
1189 1189 }
1190 1190
1191 1191 /**
1192 1192 * Convenience method that moves this component to position -1 if its
1193 1193 * parent is a <code>JLayeredPane</code>.
1194 1194 */
1195 1195 public void moveToBack() {
1196 1196 if (isIcon()) {
1197 1197 if (getDesktopIcon().getParent() instanceof JLayeredPane) {
1198 1198 ((JLayeredPane)getDesktopIcon().getParent()).
1199 1199 moveToBack(getDesktopIcon());
1200 1200 }
1201 1201 }
1202 1202 else if (getParent() instanceof JLayeredPane) {
1203 1203 ((JLayeredPane)getParent()).moveToBack(this);
1204 1204 }
1205 1205 }
1206 1206
1207 1207 /**
1208 1208 * Returns the last <code>Cursor</code> that was set by the
1209 1209 * <code>setCursor</code> method that is not a resizable
1210 1210 * <code>Cursor</code>.
1211 1211 *
1212 1212 * @return the last non-resizable <code>Cursor</code>
1213 1213 * @since 1.6
1214 1214 */
1215 1215 public Cursor getLastCursor() {
1216 1216 return lastCursor;
1217 1217 }
1218 1218
1219 1219 /**
1220 1220 * {@inheritDoc}
1221 1221 * @since 1.6
1222 1222 */
1223 1223 public void setCursor(Cursor cursor) {
1224 1224 if (cursor == null) {
1225 1225 lastCursor = null;
1226 1226 super.setCursor(cursor);
1227 1227 return;
1228 1228 }
1229 1229 int type = cursor.getType();
1230 1230 if (!(type == Cursor.SW_RESIZE_CURSOR ||
1231 1231 type == Cursor.SE_RESIZE_CURSOR ||
1232 1232 type == Cursor.NW_RESIZE_CURSOR ||
1233 1233 type == Cursor.NE_RESIZE_CURSOR ||
1234 1234 type == Cursor.N_RESIZE_CURSOR ||
1235 1235 type == Cursor.S_RESIZE_CURSOR ||
1236 1236 type == Cursor.W_RESIZE_CURSOR ||
1237 1237 type == Cursor.E_RESIZE_CURSOR)) {
1238 1238 lastCursor = cursor;
1239 1239 }
1240 1240 super.setCursor(cursor);
1241 1241 }
1242 1242
1243 1243 /**
1244 1244 * Convenience method for setting the layer attribute of this component.
1245 1245 *
1246 1246 * @param layer an <code>Integer</code> object specifying this
1247 1247 * frame's desktop layer
1248 1248 * @see JLayeredPane
1249 1249 * @beaninfo
1250 1250 * expert: true
1251 1251 * description: Specifies what desktop layer is used.
1252 1252 */
1253 1253 public void setLayer(Integer layer) {
1254 1254 if(getParent() != null && getParent() instanceof JLayeredPane) {
1255 1255 // Normally we want to do this, as it causes the LayeredPane
1256 1256 // to draw properly.
1257 1257 JLayeredPane p = (JLayeredPane)getParent();
1258 1258 p.setLayer(this, layer.intValue(), p.getPosition(this));
1259 1259 } else {
1260 1260 // Try to do the right thing
1261 1261 JLayeredPane.putLayer(this, layer.intValue());
1262 1262 if(getParent() != null)
1263 1263 getParent().repaint(getX(), getY(), getWidth(), getHeight());
1264 1264 }
1265 1265 }
1266 1266
1267 1267 /**
1268 1268 * Convenience method for setting the layer attribute of this component.
1269 1269 * The method <code>setLayer(Integer)</code> should be used for
1270 1270 * layer values predefined in <code>JLayeredPane</code>.
1271 1271 * When using <code>setLayer(int)</code>, care must be taken not to
1272 1272 * accidentally clash with those values.
1273 1273 *
1274 1274 * @param layer an integer specifying this internal frame's desktop layer
1275 1275 *
1276 1276 * @since 1.3
1277 1277 *
1278 1278 * @see #setLayer(Integer)
1279 1279 * @see JLayeredPane
1280 1280 * @beaninfo
1281 1281 * expert: true
1282 1282 * description: Specifies what desktop layer is used.
1283 1283 */
1284 1284 public void setLayer(int layer) {
1285 1285 this.setLayer(Integer.valueOf(layer));
1286 1286 }
1287 1287
1288 1288 /**
1289 1289 * Convenience method for getting the layer attribute of this component.
1290 1290 *
1291 1291 * @return an <code>Integer</code> object specifying this
1292 1292 * frame's desktop layer
1293 1293 * @see JLayeredPane
1294 1294 */
1295 1295 public int getLayer() {
1296 1296 return JLayeredPane.getLayer(this);
1297 1297 }
1298 1298
1299 1299 /**
1300 1300 * Convenience method that searches the ancestor hierarchy for a
1301 1301 * <code>JDesktop</code> instance. If <code>JInternalFrame</code>
1302 1302 * finds none, the <code>desktopIcon</code> tree is searched.
1303 1303 *
1304 1304 * @return the <code>JDesktopPane</code> this internal frame belongs to,
1305 1305 * or <code>null</code> if none is found
1306 1306 */
1307 1307 public JDesktopPane getDesktopPane() {
1308 1308 Container p;
1309 1309
1310 1310 // Search upward for desktop
1311 1311 p = getParent();
1312 1312 while(p != null && !(p instanceof JDesktopPane))
1313 1313 p = p.getParent();
1314 1314
1315 1315 if(p == null) {
1316 1316 // search its icon parent for desktop
1317 1317 p = getDesktopIcon().getParent();
1318 1318 while(p != null && !(p instanceof JDesktopPane))
1319 1319 p = p.getParent();
1320 1320 }
1321 1321
1322 1322 return (JDesktopPane)p;
1323 1323 }
1324 1324
1325 1325 /**
1326 1326 * Sets the <code>JDesktopIcon</code> associated with this
1327 1327 * <code>JInternalFrame</code>.
1328 1328 *
1329 1329 * @param d the <code>JDesktopIcon</code> to display on the desktop
1330 1330 * @see #getDesktopIcon
1331 1331 * @beaninfo
1332 1332 * bound: true
1333 1333 * description: The icon shown when this internal frame is minimized.
1334 1334 */
1335 1335 public void setDesktopIcon(JDesktopIcon d) {
1336 1336 JDesktopIcon oldValue = getDesktopIcon();
1337 1337 desktopIcon = d;
1338 1338 firePropertyChange("desktopIcon", oldValue, d);
1339 1339 }
1340 1340
1341 1341 /**
1342 1342 * Returns the <code>JDesktopIcon</code> used when this
1343 1343 * <code>JInternalFrame</code> is iconified.
1344 1344 *
1345 1345 * @return the <code>JDesktopIcon</code> displayed on the desktop
1346 1346 * @see #setDesktopIcon
1347 1347 */
1348 1348 public JDesktopIcon getDesktopIcon() {
1349 1349 return desktopIcon;
1350 1350 }
1351 1351
1352 1352 /**
1353 1353 * If the <code>JInternalFrame</code> is not in maximized state, returns
1354 1354 * <code>getBounds()</code>; otherwise, returns the bounds that the
1355 1355 * <code>JInternalFrame</code> would be restored to.
1356 1356 *
1357 1357 * @return a <code>Rectangle</code> containing the bounds of this
1358 1358 * frame when in the normal state
1359 1359 * @since 1.3
1360 1360 */
1361 1361 public Rectangle getNormalBounds() {
1362 1362
1363 1363 /* we used to test (!isMaximum) here, but since this
1364 1364 method is used by the property listener for the
1365 1365 IS_MAXIMUM_PROPERTY, it ended up getting the wrong
1366 1366 answer... Since normalBounds get set to null when the
1367 1367 frame is restored, this should work better */
1368 1368
1369 1369 if (normalBounds != null) {
1370 1370 return normalBounds;
1371 1371 } else {
1372 1372 return getBounds();
1373 1373 }
1374 1374 }
1375 1375
1376 1376 /**
1377 1377 * Sets the normal bounds for this internal frame, the bounds that
1378 1378 * this internal frame would be restored to from its maximized state.
1379 1379 * This method is intended for use only by desktop managers.
1380 1380 *
1381 1381 * @param r the bounds that this internal frame should be restored to
1382 1382 * @since 1.3
1383 1383 */
1384 1384 public void setNormalBounds(Rectangle r) {
1385 1385 normalBounds = r;
1386 1386 }
1387 1387
1388 1388 /**
1389 1389 * If this <code>JInternalFrame</code> is active,
1390 1390 * returns the child that has focus.
1391 1391 * Otherwise, returns <code>null</code>.
1392 1392 *
1393 1393 * @return the component with focus, or <code>null</code> if no children have focus
1394 1394 * @since 1.3
1395 1395 */
1396 1396 public Component getFocusOwner() {
1397 1397 if (isSelected()) {
1398 1398 return lastFocusOwner;
1399 1399 }
1400 1400 return null;
1401 1401 }
1402 1402
1403 1403 /**
1404 1404 * Returns the child component of this <code>JInternalFrame</code>
1405 1405 * that will receive the
1406 1406 * focus when this <code>JInternalFrame</code> is selected.
1407 1407 * If this <code>JInternalFrame</code> is
1408 1408 * currently selected, this method returns the same component as
1409 1409 * the <code>getFocusOwner</code> method.
1410 1410 * If this <code>JInternalFrame</code> is not selected,
1411 1411 * then the child component that most recently requested focus will be
1412 1412 * returned. If no child component has ever requested focus, then this
1413 1413 * <code>JInternalFrame</code>'s initial focusable component is returned.
1414 1414 * If no such
1415 1415 * child exists, then this <code>JInternalFrame</code>'s default component
1416 1416 * to focus is returned.
1417 1417 *
1418 1418 * @return the child component that will receive focus when this
1419 1419 * <code>JInternalFrame</code> is selected
1420 1420 * @see #getFocusOwner
1421 1421 * @see #isSelected
1422 1422 * @since 1.4
1423 1423 */
1424 1424 public Component getMostRecentFocusOwner() {
1425 1425 if (isSelected()) {
1426 1426 return getFocusOwner();
1427 1427 }
1428 1428
1429 1429 if (lastFocusOwner != null) {
1430 1430 return lastFocusOwner;
1431 1431 }
1432 1432
1433 1433 FocusTraversalPolicy policy = getFocusTraversalPolicy();
1434 1434 if (policy instanceof InternalFrameFocusTraversalPolicy) {
1435 1435 return ((InternalFrameFocusTraversalPolicy)policy).
1436 1436 getInitialComponent(this);
1437 1437 }
1438 1438
1439 1439 Component toFocus = policy.getDefaultComponent(this);
1440 1440 if (toFocus != null) {
1441 1441 return toFocus;
1442 1442 }
1443 1443 return getContentPane();
1444 1444 }
1445 1445
1446 1446 /**
1447 1447 * Requests the internal frame to restore focus to the
1448 1448 * last subcomponent that had focus. This is used by the UI when
1449 1449 * the user selected this internal frame --
1450 1450 * for example, by clicking on the title bar.
1451 1451 *
1452 1452 * @since 1.3
1453 1453 */
1454 1454 public void restoreSubcomponentFocus() {
1455 1455 if (isIcon()) {
1456 1456 SwingUtilities2.compositeRequestFocus(getDesktopIcon());
1457 1457 }
1458 1458 else {
1459 1459 Component component = KeyboardFocusManager.getCurrentKeyboardFocusManager().getPermanentFocusOwner();
1460 1460 if ((component == null) || !SwingUtilities.isDescendingFrom(component, this)) {
1461 1461 // FocusPropertyChangeListener will eventually update
1462 1462 // lastFocusOwner. As focus requests are asynchronous
1463 1463 // lastFocusOwner may be accessed before it has been correctly
1464 1464 // updated. To avoid any problems, lastFocusOwner is immediately
1465 1465 // set, assuming the request will succeed.
1466 1466 setLastFocusOwner(getMostRecentFocusOwner());
1467 1467 if (lastFocusOwner == null) {
1468 1468 // Make sure focus is restored somewhere, so that
1469 1469 // we don't leave a focused component in another frame while
1470 1470 // this frame is selected.
1471 1471 setLastFocusOwner(getContentPane());
1472 1472 }
1473 1473 lastFocusOwner.requestFocus();
1474 1474 }
1475 1475 }
1476 1476 }
1477 1477
1478 1478 private void setLastFocusOwner(Component component) {
1479 1479 lastFocusOwner = component;
1480 1480 }
1481 1481
1482 1482 /**
1483 1483 * Moves and resizes this component. Unlike other components,
1484 1484 * this implementation also forces re-layout, so that frame
1485 1485 * decorations such as the title bar are always redisplayed.
1486 1486 *
1487 1487 * @param x an integer giving the component's new horizontal position
1488 1488 * measured in pixels from the left of its container
1489 1489 * @param y an integer giving the component's new vertical position,
1490 1490 * measured in pixels from the bottom of its container
1491 1491 * @param width an integer giving the component's new width in pixels
1492 1492 * @param height an integer giving the component's new height in pixels
1493 1493 */
1494 1494 public void reshape(int x, int y, int width, int height) {
1495 1495 super.reshape(x, y, width, height);
1496 1496 validate();
1497 1497 repaint();
1498 1498 }
1499 1499
1500 1500 ///////////////////////////
1501 1501 // Frame/Window equivalents
1502 1502 ///////////////////////////
1503 1503
1504 1504 /**
1505 1505 * Adds the specified listener to receive internal
1506 1506 * frame events from this internal frame.
1507 1507 *
1508 1508 * @param l the internal frame listener
1509 1509 */
1510 1510 public void addInternalFrameListener(InternalFrameListener l) { // remind: sync ??
1511 1511 listenerList.add(InternalFrameListener.class, l);
1512 1512 // remind: needed?
1513 1513 enableEvents(0); // turn on the newEventsOnly flag in Component.
1514 1514 }
1515 1515
1516 1516 /**
1517 1517 * Removes the specified internal frame listener so that it no longer
1518 1518 * receives internal frame events from this internal frame.
1519 1519 *
1520 1520 * @param l the internal frame listener
1521 1521 */
1522 1522 public void removeInternalFrameListener(InternalFrameListener l) { // remind: sync??
1523 1523 listenerList.remove(InternalFrameListener.class, l);
1524 1524 }
1525 1525
1526 1526 /**
1527 1527 * Returns an array of all the <code>InternalFrameListener</code>s added
1528 1528 * to this <code>JInternalFrame</code> with
1529 1529 * <code>addInternalFrameListener</code>.
1530 1530 *
1531 1531 * @return all of the <code>InternalFrameListener</code>s added or an empty
1532 1532 * array if no listeners have been added
1533 1533 * @since 1.4
1534 1534 *
1535 1535 * @see #addInternalFrameListener
1536 1536 */
1537 1537 public InternalFrameListener[] getInternalFrameListeners() {
1538 1538 return listenerList.getListeners(InternalFrameListener.class);
1539 1539 }
1540 1540
1541 1541 // remind: name ok? all one method ok? need to be synchronized?
1542 1542 /**
1543 1543 * Fires an internal frame event.
1544 1544 *
1545 1545 * @param id the type of the event being fired; one of the following:
1546 1546 * <ul>
1547 1547 * <li><code>InternalFrameEvent.INTERNAL_FRAME_OPENED</code>
1548 1548 * <li><code>InternalFrameEvent.INTERNAL_FRAME_CLOSING</code>
1549 1549 * <li><code>InternalFrameEvent.INTERNAL_FRAME_CLOSED</code>
1550 1550 * <li><code>InternalFrameEvent.INTERNAL_FRAME_ICONIFIED</code>
1551 1551 * <li><code>InternalFrameEvent.INTERNAL_FRAME_DEICONIFIED</code>
1552 1552 * <li><code>InternalFrameEvent.INTERNAL_FRAME_ACTIVATED</code>
1553 1553 * <li><code>InternalFrameEvent.INTERNAL_FRAME_DEACTIVATED</code>
1554 1554 * </ul>
1555 1555 * If the event type is not one of the above, nothing happens.
1556 1556 */
1557 1557 protected void fireInternalFrameEvent(int id){
1558 1558 Object[] listeners = listenerList.getListenerList();
1559 1559 InternalFrameEvent e = null;
1560 1560 for (int i = listeners.length -2; i >=0; i -= 2){
1561 1561 if (listeners[i] == InternalFrameListener.class){
1562 1562 if (e == null){
1563 1563 e = new InternalFrameEvent(this, id);
1564 1564 // System.out.println("InternalFrameEvent: " + e.paramString());
1565 1565 }
1566 1566 switch(e.getID()) {
1567 1567 case InternalFrameEvent.INTERNAL_FRAME_OPENED:
1568 1568 ((InternalFrameListener)listeners[i+1]).internalFrameOpened(e);
1569 1569 break;
1570 1570 case InternalFrameEvent.INTERNAL_FRAME_CLOSING:
1571 1571 ((InternalFrameListener)listeners[i+1]).internalFrameClosing(e);
1572 1572 break;
1573 1573 case InternalFrameEvent.INTERNAL_FRAME_CLOSED:
1574 1574 ((InternalFrameListener)listeners[i+1]).internalFrameClosed(e);
1575 1575 break;
1576 1576 case InternalFrameEvent.INTERNAL_FRAME_ICONIFIED:
1577 1577 ((InternalFrameListener)listeners[i+1]).internalFrameIconified(e);
1578 1578 break;
1579 1579 case InternalFrameEvent.INTERNAL_FRAME_DEICONIFIED:
1580 1580 ((InternalFrameListener)listeners[i+1]).internalFrameDeiconified(e);
1581 1581 break;
1582 1582 case InternalFrameEvent.INTERNAL_FRAME_ACTIVATED:
1583 1583 ((InternalFrameListener)listeners[i+1]).internalFrameActivated(e);
1584 1584 break;
1585 1585 case InternalFrameEvent.INTERNAL_FRAME_DEACTIVATED:
1586 1586 ((InternalFrameListener)listeners[i+1]).internalFrameDeactivated(e);
1587 1587 break;
1588 1588 default:
1589 1589 break;
1590 1590 }
1591 1591 }
1592 1592 }
1593 1593 /* we could do it off the event, but at the moment, that's not how
1594 1594 I'm implementing it */
1595 1595 // if (id == InternalFrameEvent.INTERNAL_FRAME_CLOSING) {
1596 1596 // doDefaultCloseAction();
1597 1597 // }
1598 1598 }
1599 1599
1600 1600 /**
1601 1601 * Fires an
1602 1602 * <code>INTERNAL_FRAME_CLOSING</code> event
1603 1603 * and then performs the action specified by
1604 1604 * the internal frame's default close operation.
1605 1605 * This method is typically invoked by the
1606 1606 * look-and-feel-implemented action handler
1607 1607 * for the internal frame's close button.
1608 1608 *
1609 1609 * @since 1.3
1610 1610 * @see #setDefaultCloseOperation
1611 1611 * @see javax.swing.event.InternalFrameEvent#INTERNAL_FRAME_CLOSING
1612 1612 */
1613 1613 public void doDefaultCloseAction() {
1614 1614 fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_CLOSING);
1615 1615 switch(defaultCloseOperation) {
1616 1616 case DO_NOTHING_ON_CLOSE:
1617 1617 break;
1618 1618 case HIDE_ON_CLOSE:
1619 1619 setVisible(false);
1620 1620 if (isSelected())
1621 1621 try {
1622 1622 setSelected(false);
1623 1623 } catch (PropertyVetoException pve) {}
1624 1624
1625 1625 /* should this activate the next frame? that's really
1626 1626 desktopmanager's policy... */
1627 1627 break;
1628 1628 case DISPOSE_ON_CLOSE:
1629 1629 try {
1630 1630 fireVetoableChange(IS_CLOSED_PROPERTY, Boolean.FALSE,
1631 1631 Boolean.TRUE);
1632 1632 isClosed = true;
1633 1633 setVisible(false);
1634 1634 firePropertyChange(IS_CLOSED_PROPERTY, Boolean.FALSE,
1635 1635 Boolean.TRUE);
1636 1636 dispose();
1637 1637 } catch (PropertyVetoException pve) {}
1638 1638 break;
1639 1639 default:
1640 1640 break;
1641 1641 }
1642 1642 }
1643 1643
1644 1644 /**
1645 1645 * Sets the operation that will happen by default when
1646 1646 * the user initiates a "close" on this internal frame.
1647 1647 * The possible choices are:
1648 1648 * <br><br>
1649 1649 * <dl>
1650 1650 * <dt><code>DO_NOTHING_ON_CLOSE</code>
1651 1651 * <dd> Do nothing.
1652 1652 * This requires the program to handle the operation
1653 1653 * in the <code>windowClosing</code> method
1654 1654 * of a registered <code>InternalFrameListener</code> object.
1655 1655 * <dt><code>HIDE_ON_CLOSE</code>
1656 1656 * <dd> Automatically make the internal frame invisible.
1657 1657 * <dt><code>DISPOSE_ON_CLOSE</code>
1658 1658 * <dd> Automatically dispose of the internal frame.
1659 1659 * </dl>
1660 1660 * <p>
1661 1661 * The default value is <code>DISPOSE_ON_CLOSE</code>.
1662 1662 * Before performing the specified close operation,
1663 1663 * the internal frame fires
1664 1664 * an <code>INTERNAL_FRAME_CLOSING</code> event.
1665 1665 *
1666 1666 * @param operation one of the following constants defined in
1667 1667 * <code>javax.swing.WindowConstants</code>
1668 1668 * (an interface implemented by
1669 1669 * <code>JInternalFrame</code>):
1670 1670 * <code>DO_NOTHING_ON_CLOSE</code>,
1671 1671 * <code>HIDE_ON_CLOSE</code>, or
1672 1672 * <code>DISPOSE_ON_CLOSE</code>
1673 1673 *
1674 1674 * @see #addInternalFrameListener
1675 1675 * @see #getDefaultCloseOperation
1676 1676 * @see #setVisible
1677 1677 * @see #dispose
1678 1678 * @see InternalFrameEvent#INTERNAL_FRAME_CLOSING
1679 1679 */
1680 1680 public void setDefaultCloseOperation(int operation) {
1681 1681 this.defaultCloseOperation = operation;
1682 1682 }
1683 1683
1684 1684 /**
1685 1685 * Returns the default operation that occurs when the user
1686 1686 * initiates a "close" on this internal frame.
1687 1687 * @return the operation that will occur when the user closes the internal
1688 1688 * frame
1689 1689 * @see #setDefaultCloseOperation
1690 1690 */
1691 1691 public int getDefaultCloseOperation() {
1692 1692 return defaultCloseOperation;
1693 1693 }
1694 1694
1695 1695 /**
1696 1696 * Causes subcomponents of this <code>JInternalFrame</code>
1697 1697 * to be laid out at their preferred size. Internal frames that are
1698 1698 * iconized or maximized are first restored and then packed. If the
1699 1699 * internal frame is unable to be restored its state is not changed
1700 1700 * and will not be packed.
1701 1701 *
1702 1702 * @see java.awt.Window#pack
1703 1703 */
1704 1704 public void pack() {
1705 1705 try {
1706 1706 if (isIcon()) {
1707 1707 setIcon(false);
1708 1708 } else if (isMaximum()) {
1709 1709 setMaximum(false);
1710 1710 }
1711 1711 } catch(PropertyVetoException e) {
1712 1712 return;
1713 1713 }
1714 1714 setSize(getPreferredSize());
1715 1715 validate();
1716 1716 }
1717 1717
1718 1718 /**
1719 1719 * If the internal frame is not visible,
1720 1720 * brings the internal frame to the front,
1721 1721 * makes it visible,
1722 1722 * and attempts to select it.
1723 1723 * The first time the internal frame is made visible,
1724 1724 * this method also fires an <code>INTERNAL_FRAME_OPENED</code> event.
1725 1725 * This method does nothing if the internal frame is already visible.
1726 1726 * Invoking this method
1727 1727 * has the same result as invoking
1728 1728 * <code>setVisible(true)</code>.
1729 1729 *
1730 1730 * @see #moveToFront
1731 1731 * @see #setSelected
1732 1732 * @see InternalFrameEvent#INTERNAL_FRAME_OPENED
1733 1733 * @see #setVisible
1734 1734 */
1735 1735 public void show() {
1736 1736 // bug 4312922
1737 1737 if (isVisible()) {
1738 1738 //match the behavior of setVisible(true): do nothing
1739 1739 return;
1740 1740 }
1741 1741
1742 1742 // bug 4149505
1743 1743 if (!opened) {
1744 1744 fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_OPENED);
1745 1745 opened = true;
1746 1746 }
1747 1747
1748 1748 /* icon default visibility is false; set it to true so that it shows
1749 1749 up when user iconifies frame */
1750 1750 getDesktopIcon().setVisible(true);
1751 1751
1752 1752 toFront();
1753 1753 super.show();
1754 1754
1755 1755 if (isIcon) {
1756 1756 return;
1757 1757 }
1758 1758
1759 1759 if (!isSelected()) {
1760 1760 try {
1761 1761 setSelected(true);
1762 1762 } catch (PropertyVetoException pve) {}
1763 1763 }
1764 1764 }
1765 1765
1766 1766 public void hide() {
1767 1767 if (isIcon()) {
1768 1768 getDesktopIcon().setVisible(false);
1769 1769 }
1770 1770 super.hide();
1771 1771 }
1772 1772
1773 1773 /**
1774 1774 * Makes this internal frame
1775 1775 * invisible, unselected, and closed.
1776 1776 * If the frame is not already closed,
1777 1777 * this method fires an
1778 1778 * <code>INTERNAL_FRAME_CLOSED</code> event.
1779 1779 * The results of invoking this method are similar to
1780 1780 * <code>setClosed(true)</code>,
1781 1781 * but <code>dispose</code> always succeeds in closing
1782 1782 * the internal frame and does not fire
1783 1783 * an <code>INTERNAL_FRAME_CLOSING</code> event.
1784 1784 *
1785 1785 * @see javax.swing.event.InternalFrameEvent#INTERNAL_FRAME_CLOSED
1786 1786 * @see #setVisible
1787 1787 * @see #setSelected
1788 1788 * @see #setClosed
1789 1789 */
1790 1790 public void dispose() {
1791 1791 if (isVisible()) {
1792 1792 setVisible(false);
1793 1793 }
1794 1794 if (isSelected()) {
1795 1795 try {
1796 1796 setSelected(false);
1797 1797 } catch (PropertyVetoException pve) {}
1798 1798 }
1799 1799 if (!isClosed) {
1800 1800 firePropertyChange(IS_CLOSED_PROPERTY, Boolean.FALSE, Boolean.TRUE);
1801 1801 isClosed = true;
1802 1802 }
1803 1803 fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_CLOSED);
1804 1804 }
1805 1805
1806 1806 /**
1807 1807 * Brings this internal frame to the front.
1808 1808 * Places this internal frame at the top of the stacking order
1809 1809 * and makes the corresponding adjustment to other visible internal
1810 1810 * frames.
1811 1811 *
1812 1812 * @see java.awt.Window#toFront
1813 1813 * @see #moveToFront
1814 1814 */
1815 1815 public void toFront() {
1816 1816 moveToFront();
1817 1817 }
1818 1818
1819 1819 /**
1820 1820 * Sends this internal frame to the back.
1821 1821 * Places this internal frame at the bottom of the stacking order
1822 1822 * and makes the corresponding adjustment to other visible
1823 1823 * internal frames.
1824 1824 *
1825 1825 * @see java.awt.Window#toBack
1826 1826 * @see #moveToBack
1827 1827 */
1828 1828 public void toBack() {
1829 1829 moveToBack();
1830 1830 }
1831 1831
1832 1832 /**
1833 1833 * Does nothing because <code>JInternalFrame</code>s must always be roots of a focus
1834 1834 * traversal cycle.
1835 1835 *
1836 1836 * @param focusCycleRoot this value is ignored
1837 1837 * @see #isFocusCycleRoot
1838 1838 * @see java.awt.Container#setFocusTraversalPolicy
1839 1839 * @see java.awt.Container#getFocusTraversalPolicy
1840 1840 * @since 1.4
1841 1841 */
1842 1842 public final void setFocusCycleRoot(boolean focusCycleRoot) {
1843 1843 }
1844 1844
1845 1845 /**
1846 1846 * Always returns <code>true</code> because all <code>JInternalFrame</code>s must be
1847 1847 * roots of a focus traversal cycle.
1848 1848 *
1849 1849 * @return <code>true</code>
1850 1850 * @see #setFocusCycleRoot
1851 1851 * @see java.awt.Container#setFocusTraversalPolicy
1852 1852 * @see java.awt.Container#getFocusTraversalPolicy
1853 1853 * @since 1.4
1854 1854 */
1855 1855 public final boolean isFocusCycleRoot() {
1856 1856 return true;
1857 1857 }
1858 1858
1859 1859 /**
1860 1860 * Always returns <code>null</code> because <code>JInternalFrame</code>s
1861 1861 * must always be roots of a focus
1862 1862 * traversal cycle.
1863 1863 *
1864 1864 * @return <code>null</code>
1865 1865 * @see java.awt.Container#isFocusCycleRoot()
1866 1866 * @since 1.4
1867 1867 */
1868 1868 public final Container getFocusCycleRootAncestor() {
1869 1869 return null;
1870 1870 }
1871 1871
1872 1872 /**
1873 1873 * Gets the warning string that is displayed with this internal frame.
1874 1874 * Since an internal frame is always secure (since it's fully
1875 1875 * contained within a window that might need a warning string)
1876 1876 * this method always returns <code>null</code>.
1877 1877 * @return <code>null</code>
1878 1878 * @see java.awt.Window#getWarningString
1879 1879 */
1880 1880 public final String getWarningString() {
1881 1881 return null;
1882 1882 }
1883 1883
1884 1884 /**
1885 1885 * See <code>readObject</code> and <code>writeObject</code>
1886 1886 * in <code>JComponent</code> for more
1887 1887 * information about serialization in Swing.
1888 1888 */
1889 1889 private void writeObject(ObjectOutputStream s) throws IOException {
1890 1890 s.defaultWriteObject();
1891 1891 if (getUIClassID().equals(uiClassID)) {
1892 1892 byte count = JComponent.getWriteObjCounter(this);
1893 1893 JComponent.setWriteObjCounter(this, --count);
1894 1894 if (count == 0 && ui != null) {
1895 1895 boolean old = isRootPaneCheckingEnabled();
1896 1896 try {
1897 1897 setRootPaneCheckingEnabled(false);
1898 1898 ui.installUI(this);
1899 1899 } finally {
1900 1900 setRootPaneCheckingEnabled(old);
1901 1901 }
1902 1902 }
1903 1903 }
1904 1904 }
1905 1905
1906 1906 /* Called from the JComponent's EnableSerializationFocusListener to
1907 1907 * do any Swing-specific pre-serialization configuration.
1908 1908 */
1909 1909 void compWriteObjectNotify() {
1910 1910 // need to disable rootpane checking for InternalFrame: 4172083
1911 1911 boolean old = isRootPaneCheckingEnabled();
1912 1912 try {
1913 1913 setRootPaneCheckingEnabled(false);
1914 1914 super.compWriteObjectNotify();
1915 1915 }
1916 1916 finally {
1917 1917 setRootPaneCheckingEnabled(old);
1918 1918 }
1919 1919 }
1920 1920
1921 1921 /**
1922 1922 * Returns a string representation of this <code>JInternalFrame</code>.
1923 1923 * This method
1924 1924 * is intended to be used only for debugging purposes, and the
1925 1925 * content and format of the returned string may vary between
1926 1926 * implementations. The returned string may be empty but may not
1927 1927 * be <code>null</code>.
1928 1928 *
1929 1929 * @return a string representation of this <code>JInternalFrame</code>
1930 1930 */
1931 1931 protected String paramString() {
1932 1932 String rootPaneString = (rootPane != null ?
1933 1933 rootPane.toString() : "");
1934 1934 String rootPaneCheckingEnabledString = (rootPaneCheckingEnabled ?
1935 1935 "true" : "false");
1936 1936 String closableString = (closable ? "true" : "false");
1937 1937 String isClosedString = (isClosed ? "true" : "false");
1938 1938 String maximizableString = (maximizable ? "true" : "false");
1939 1939 String isMaximumString = (isMaximum ? "true" : "false");
1940 1940 String iconableString = (iconable ? "true" : "false");
1941 1941 String isIconString = (isIcon ? "true" : "false");
1942 1942 String resizableString = (resizable ? "true" : "false");
1943 1943 String isSelectedString = (isSelected ? "true" : "false");
1944 1944 String frameIconString = (frameIcon != null ?
1945 1945 frameIcon.toString() : "");
1946 1946 String titleString = (title != null ?
1947 1947 title : "");
1948 1948 String desktopIconString = (desktopIcon != null ?
1949 1949 desktopIcon.toString() : "");
1950 1950 String openedString = (opened ? "true" : "false");
1951 1951 String defaultCloseOperationString;
1952 1952 if (defaultCloseOperation == HIDE_ON_CLOSE) {
1953 1953 defaultCloseOperationString = "HIDE_ON_CLOSE";
1954 1954 } else if (defaultCloseOperation == DISPOSE_ON_CLOSE) {
1955 1955 defaultCloseOperationString = "DISPOSE_ON_CLOSE";
1956 1956 } else if (defaultCloseOperation == DO_NOTHING_ON_CLOSE) {
1957 1957 defaultCloseOperationString = "DO_NOTHING_ON_CLOSE";
1958 1958 } else defaultCloseOperationString = "";
1959 1959
1960 1960 return super.paramString() +
1961 1961 ",closable=" + closableString +
1962 1962 ",defaultCloseOperation=" + defaultCloseOperationString +
1963 1963 ",desktopIcon=" + desktopIconString +
1964 1964 ",frameIcon=" + frameIconString +
1965 1965 ",iconable=" + iconableString +
1966 1966 ",isClosed=" + isClosedString +
1967 1967 ",isIcon=" + isIconString +
1968 1968 ",isMaximum=" + isMaximumString +
1969 1969 ",isSelected=" + isSelectedString +
1970 1970 ",maximizable=" + maximizableString +
1971 1971 ",opened=" + openedString +
1972 1972 ",resizable=" + resizableString +
1973 1973 ",rootPane=" + rootPaneString +
1974 1974 ",rootPaneCheckingEnabled=" + rootPaneCheckingEnabledString +
1975 1975 ",title=" + titleString;
1976 1976 }
1977 1977
1978 1978 // ======= begin optimized frame dragging defence code ==============
1979 1979
1980 1980 boolean isDragging = false;
1981 1981 boolean danger = false;
1982 1982
1983 1983 /**
1984 1984 * Overridden to allow optimized painting when the
1985 1985 * internal frame is being dragged.
1986 1986 */
1987 1987 protected void paintComponent(Graphics g) {
1988 1988 if (isDragging) {
1989 1989 // System.out.println("ouch");
1990 1990 danger = true;
1991 1991 }
1992 1992
1993 1993 super.paintComponent(g);
1994 1994 }
1995 1995
1996 1996 // ======= end optimized frame dragging defence code ==============
1997 1997
1998 1998 /////////////////
1999 1999 // Accessibility support
2000 2000 ////////////////
2001 2001
2002 2002 /**
2003 2003 * Gets the <code>AccessibleContext</code> associated with this
2004 2004 * <code>JInternalFrame</code>.
2005 2005 * For internal frames, the <code>AccessibleContext</code>
2006 2006 * takes the form of an
2007 2007 * <code>AccessibleJInternalFrame</code> object.
2008 2008 * A new <code>AccessibleJInternalFrame</code> instance is created if necessary.
2009 2009 *
2010 2010 * @return an <code>AccessibleJInternalFrame</code> that serves as the
2011 2011 * <code>AccessibleContext</code> of this
2012 2012 * <code>JInternalFrame</code>
2013 2013 * @see AccessibleJInternalFrame
2014 2014 */
2015 2015 public AccessibleContext getAccessibleContext() {
2016 2016 if (accessibleContext == null) {
2017 2017 accessibleContext = new AccessibleJInternalFrame();
2018 2018 }
2019 2019 return accessibleContext;
2020 2020 }
2021 2021
2022 2022 /**
2023 2023 * This class implements accessibility support for the
2024 2024 * <code>JInternalFrame</code> class. It provides an implementation of the
2025 2025 * Java Accessibility API appropriate to internal frame user-interface
2026 2026 * elements.
2027 2027 * <p>
2028 2028 * <strong>Warning:</strong>
2029 2029 * Serialized objects of this class will not be compatible with
2030 2030 * future Swing releases. The current serialization support is
2031 2031 * appropriate for short term storage or RMI between applications running
2032 2032 * the same version of Swing. As of 1.4, support for long term storage
2033 2033 * of all JavaBeans™
2034 2034 * has been added to the <code>java.beans</code> package.
2035 2035 * Please see {@link java.beans.XMLEncoder}.
2036 2036 */
2037 2037 protected class AccessibleJInternalFrame extends AccessibleJComponent
2038 2038 implements AccessibleValue {
2039 2039
2040 2040 /**
2041 2041 * Get the accessible name of this object.
2042 2042 *
2043 2043 * @return the localized name of the object -- can be <code>null</code> if this
2044 2044 * object does not have a name
2045 2045 * @see #setAccessibleName
2046 2046 */
2047 2047 public String getAccessibleName() {
2048 2048 String name = accessibleName;
2049 2049
2050 2050 if (name == null) {
2051 2051 name = (String)getClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY);
2052 2052 }
2053 2053 if (name == null) {
2054 2054 name = getTitle();
2055 2055 }
2056 2056 return name;
2057 2057 }
2058 2058
2059 2059 /**
2060 2060 * Get the role of this object.
2061 2061 *
2062 2062 * @return an instance of AccessibleRole describing the role of the
2063 2063 * object
2064 2064 * @see AccessibleRole
2065 2065 */
2066 2066 public AccessibleRole getAccessibleRole() {
2067 2067 return AccessibleRole.INTERNAL_FRAME;
2068 2068 }
2069 2069
2070 2070 /**
2071 2071 * Gets the AccessibleValue associated with this object. In the
2072 2072 * implementation of the Java Accessibility API for this class,
2073 2073 * returns this object, which is responsible for implementing the
2074 2074 * <code>AccessibleValue</code> interface on behalf of itself.
2075 2075 *
2076 2076 * @return this object
2077 2077 */
2078 2078 public AccessibleValue getAccessibleValue() {
2079 2079 return this;
2080 2080 }
2081 2081
2082 2082
2083 2083 //
2084 2084 // AccessibleValue methods
2085 2085 //
2086 2086
2087 2087 /**
2088 2088 * Get the value of this object as a Number.
2089 2089 *
2090 2090 * @return value of the object -- can be <code>null</code> if this object does not
2091 2091 * have a value
2092 2092 */
2093 2093 public Number getCurrentAccessibleValue() {
2094 2094 return Integer.valueOf(getLayer());
2095 2095 }
2096 2096
2097 2097 /**
2098 2098 * Set the value of this object as a Number.
2099 2099 *
2100 2100 * @return <code>true</code> if the value was set
2101 2101 */
2102 2102 public boolean setCurrentAccessibleValue(Number n) {
2103 2103 // TIGER - 4422535
2104 2104 if (n == null) {
2105 2105 return false;
2106 2106 }
2107 2107 setLayer(new Integer(n.intValue()));
2108 2108 return true;
2109 2109 }
2110 2110
2111 2111 /**
2112 2112 * Get the minimum value of this object as a Number.
2113 2113 *
2114 2114 * @return Minimum value of the object; <code>null</code> if this object does not
2115 2115 * have a minimum value
2116 2116 */
2117 2117 public Number getMinimumAccessibleValue() {
2118 2118 return Integer.MIN_VALUE;
2119 2119 }
2120 2120
2121 2121 /**
2122 2122 * Get the maximum value of this object as a Number.
2123 2123 *
2124 2124 * @return Maximum value of the object; <code>null</code> if this object does not
2125 2125 * have a maximum value
2126 2126 */
2127 2127 public Number getMaximumAccessibleValue() {
2128 2128 return Integer.MAX_VALUE;
2129 2129 }
2130 2130
2131 2131 } // AccessibleJInternalFrame
2132 2132
2133 2133 /**
2134 2134 * This component represents an iconified version of a
2135 2135 * <code>JInternalFrame</code>.
2136 2136 * This API should NOT BE USED by Swing applications, as it will go
2137 2137 * away in future versions of Swing as its functionality is moved into
2138 2138 * <code>JInternalFrame</code>. This class is public only so that
2139 2139 * UI objects can display a desktop icon. If an application
2140 2140 * wants to display a desktop icon, it should create a
2141 2141 * <code>JInternalFrame</code> instance and iconify it.
2142 2142 * <p>
2143 2143 * <strong>Warning:</strong>
2144 2144 * Serialized objects of this class will not be compatible with
2145 2145 * future Swing releases. The current serialization support is
2146 2146 * appropriate for short term storage or RMI between applications running
2147 2147 * the same version of Swing. As of 1.4, support for long term storage
2148 2148 * of all JavaBeans™
2149 2149 * has been added to the <code>java.beans</code> package.
2150 2150 * Please see {@link java.beans.XMLEncoder}.
2151 2151 *
2152 2152 * @author David Kloba
2153 2153 */
2154 2154 static public class JDesktopIcon extends JComponent implements Accessible
2155 2155 {
2156 2156 JInternalFrame internalFrame;
2157 2157
2158 2158 /**
2159 2159 * Creates an icon for an internal frame.
2160 2160 *
2161 2161 * @param f the <code>JInternalFrame</code>
2162 2162 * for which the icon is created
2163 2163 */
2164 2164 public JDesktopIcon(JInternalFrame f) {
2165 2165 setVisible(false);
2166 2166 setInternalFrame(f);
2167 2167 updateUI();
2168 2168 }
2169 2169
2170 2170 /**
2171 2171 * Returns the look-and-feel object that renders this component.
2172 2172 *
2173 2173 * @return the <code>DesktopIconUI</code> object that renders
2174 2174 * this component
2175 2175 */
2176 2176 public DesktopIconUI getUI() {
2177 2177 return (DesktopIconUI)ui;
2178 2178 }
2179 2179
2180 2180 /**
2181 2181 * Sets the look-and-feel object that renders this component.
2182 2182 *
2183 2183 * @param ui the <code>DesktopIconUI</code> look-and-feel object
2184 2184 * @see UIDefaults#getUI
2185 2185 */
2186 2186 public void setUI(DesktopIconUI ui) {
2187 2187 super.setUI(ui);
2188 2188 }
2189 2189
2190 2190 /**
2191 2191 * Returns the <code>JInternalFrame</code> that this
2192 2192 * <code>DesktopIcon</code> is associated with.
2193 2193 *
2194 2194 * @return the <code>JInternalFrame</code> with which this icon
2195 2195 * is associated
2196 2196 */
2197 2197 public JInternalFrame getInternalFrame() {
2198 2198 return internalFrame;
2199 2199 }
2200 2200
2201 2201 /**
2202 2202 * Sets the <code>JInternalFrame</code> with which this
2203 2203 * <code>DesktopIcon</code> is associated.
2204 2204 *
2205 2205 * @param f the <code>JInternalFrame</code> with which this icon
2206 2206 * is associated
2207 2207 */
2208 2208 public void setInternalFrame(JInternalFrame f) {
2209 2209 internalFrame = f;
2210 2210 }
2211 2211
2212 2212 /**
2213 2213 * Convenience method to ask the icon for the <code>Desktop</code>
2214 2214 * object it belongs to.
2215 2215 *
2216 2216 * @return the <code>JDesktopPane</code> that contains this
2217 2217 * icon's internal frame, or <code>null</code> if none found
2218 2218 */
2219 2219 public JDesktopPane getDesktopPane() {
2220 2220 if(getInternalFrame() != null)
2221 2221 return getInternalFrame().getDesktopPane();
2222 2222 return null;
2223 2223 }
2224 2224
2225 2225 /**
2226 2226 * Notification from the <code>UIManager</code> that the look and feel
2227 2227 * has changed.
2228 2228 * Replaces the current UI object with the latest version from the
2229 2229 * <code>UIManager</code>.
2230 2230 *
2231 2231 * @see JComponent#updateUI
2232 2232 */
2233 2233 public void updateUI() {
2234 2234 boolean hadUI = (ui != null);
2235 2235 setUI((DesktopIconUI)UIManager.getUI(this));
2236 2236 invalidate();
2237 2237
2238 2238 Dimension r = getPreferredSize();
2239 2239 setSize(r.width, r.height);
2240 2240
2241 2241
2242 2242 if (internalFrame != null && internalFrame.getUI() != null) { // don't do this if UI not created yet
2243 2243 SwingUtilities.updateComponentTreeUI(internalFrame);
2244 2244 }
2245 2245 }
2246 2246
2247 2247 /* This method is called if updateUI was called on the associated
2248 2248 * JInternalFrame. It's necessary to avoid infinite recursion.
2249 2249 */
2250 2250 void updateUIWhenHidden() {
2251 2251 /* Update this UI and any associated internal frame */
2252 2252 setUI((DesktopIconUI)UIManager.getUI(this));
2253 2253
2254 2254 Dimension r = getPreferredSize();
2255 2255 setSize(r.width, r.height);
2256 2256
2257 2257 invalidate();
2258 2258 Component[] children = getComponents();
2259 2259 if (children != null) {
2260 2260 for (Component child : children) {
2261 2261 SwingUtilities.updateComponentTreeUI(child);
2262 2262 }
2263 2263 }
2264 2264 }
2265 2265
2266 2266 /**
2267 2267 * Returns the name of the look-and-feel
2268 2268 * class that renders this component.
2269 2269 *
2270 2270 * @return the string "DesktopIconUI"
2271 2271 * @see JComponent#getUIClassID
2272 2272 * @see UIDefaults#getUI
2273 2273 */
2274 2274 public String getUIClassID() {
2275 2275 return "DesktopIconUI";
2276 2276 }
2277 2277 ////////////////
2278 2278 // Serialization support
2279 2279 ////////////////
2280 2280 private void writeObject(ObjectOutputStream s) throws IOException {
2281 2281 s.defaultWriteObject();
2282 2282 if (getUIClassID().equals("DesktopIconUI")) {
2283 2283 byte count = JComponent.getWriteObjCounter(this);
2284 2284 JComponent.setWriteObjCounter(this, --count);
2285 2285 if (count == 0 && ui != null) {
2286 2286 ui.installUI(this);
2287 2287 }
2288 2288 }
2289 2289 }
2290 2290
2291 2291 /////////////////
2292 2292 // Accessibility support
2293 2293 ////////////////
2294 2294
2295 2295 /**
2296 2296 * Gets the AccessibleContext associated with this JDesktopIcon.
2297 2297 * For desktop icons, the AccessibleContext takes the form of an
2298 2298 * AccessibleJDesktopIcon.
2299 2299 * A new AccessibleJDesktopIcon instance is created if necessary.
2300 2300 *
2301 2301 * @return an AccessibleJDesktopIcon that serves as the
2302 2302 * AccessibleContext of this JDesktopIcon
2303 2303 */
2304 2304 public AccessibleContext getAccessibleContext() {
2305 2305 if (accessibleContext == null) {
2306 2306 accessibleContext = new AccessibleJDesktopIcon();
2307 2307 }
2308 2308 return accessibleContext;
2309 2309 }
2310 2310
2311 2311 /**
2312 2312 * This class implements accessibility support for the
2313 2313 * <code>JInternalFrame.JDesktopIcon</code> class. It provides an
2314 2314 * implementation of the Java Accessibility API appropriate to
2315 2315 * desktop icon user-interface elements.
2316 2316 * <p>
2317 2317 * <strong>Warning:</strong>
2318 2318 * Serialized objects of this class will not be compatible with
2319 2319 * future Swing releases. The current serialization support is
2320 2320 * appropriate for short term storage or RMI between applications running
2321 2321 * the same version of Swing. As of 1.4, support for long term storage
2322 2322 * of all JavaBeans™
2323 2323 * has been added to the <code>java.beans</code> package.
2324 2324 * Please see {@link java.beans.XMLEncoder}.
2325 2325 */
2326 2326 protected class AccessibleJDesktopIcon extends AccessibleJComponent
2327 2327 implements AccessibleValue {
2328 2328
2329 2329 /**
2330 2330 * Gets the role of this object.
2331 2331 *
2332 2332 * @return an instance of AccessibleRole describing the role of the
2333 2333 * object
2334 2334 * @see AccessibleRole
2335 2335 */
2336 2336 public AccessibleRole getAccessibleRole() {
2337 2337 return AccessibleRole.DESKTOP_ICON;
2338 2338 }
2339 2339
2340 2340 /**
2341 2341 * Gets the AccessibleValue associated with this object. In the
2342 2342 * implementation of the Java Accessibility API for this class,
2343 2343 * returns this object, which is responsible for implementing the
2344 2344 * <code>AccessibleValue</code> interface on behalf of itself.
2345 2345 *
2346 2346 * @return this object
2347 2347 */
2348 2348 public AccessibleValue getAccessibleValue() {
2349 2349 return this;
2350 2350 }
2351 2351
2352 2352 //
2353 2353 // AccessibleValue methods
2354 2354 //
2355 2355
2356 2356 /**
2357 2357 * Gets the value of this object as a <code>Number</code>.
2358 2358 *
2359 2359 * @return value of the object -- can be <code>null</code> if this object does not
2360 2360 * have a value
2361 2361 */
2362 2362 public Number getCurrentAccessibleValue() {
2363 2363 AccessibleContext a = JDesktopIcon.this.getInternalFrame().getAccessibleContext();
2364 2364 AccessibleValue v = a.getAccessibleValue();
2365 2365 if (v != null) {
2366 2366 return v.getCurrentAccessibleValue();
2367 2367 } else {
2368 2368 return null;
2369 2369 }
2370 2370 }
2371 2371
2372 2372 /**
2373 2373 * Sets the value of this object as a <code>Number</code>.
2374 2374 *
2375 2375 * @return <code>true</code> if the value was set
2376 2376 */
2377 2377 public boolean setCurrentAccessibleValue(Number n) {
2378 2378 // TIGER - 4422535
2379 2379 if (n == null) {
2380 2380 return false;
2381 2381 }
2382 2382 AccessibleContext a = JDesktopIcon.this.getInternalFrame().getAccessibleContext();
2383 2383 AccessibleValue v = a.getAccessibleValue();
2384 2384 if (v != null) {
2385 2385 return v.setCurrentAccessibleValue(n);
2386 2386 } else {
2387 2387 return false;
2388 2388 }
2389 2389 }
2390 2390
2391 2391 /**
2392 2392 * Gets the minimum value of this object as a <code>Number</code>.
2393 2393 *
2394 2394 * @return minimum value of the object; <code>null</code> if this object does not
2395 2395 * have a minimum value
2396 2396 */
2397 2397 public Number getMinimumAccessibleValue() {
2398 2398 AccessibleContext a = JDesktopIcon.this.getInternalFrame().getAccessibleContext();
2399 2399 if (a instanceof AccessibleValue) {
2400 2400 return ((AccessibleValue)a).getMinimumAccessibleValue();
2401 2401 } else {
2402 2402 return null;
2403 2403 }
2404 2404 }
2405 2405
2406 2406 /**
2407 2407 * Gets the maximum value of this object as a <code>Number</code>.
2408 2408 *
2409 2409 * @return maximum value of the object; <code>null</code> if this object does not
2410 2410 * have a maximum value
2411 2411 */
2412 2412 public Number getMaximumAccessibleValue() {
2413 2413 AccessibleContext a = JDesktopIcon.this.getInternalFrame().getAccessibleContext();
2414 2414 if (a instanceof AccessibleValue) {
2415 2415 return ((AccessibleValue)a).getMaximumAccessibleValue();
2416 2416 } else {
2417 2417 return null;
2418 2418 }
2419 2419 }
2420 2420
2421 2421 } // AccessibleJDesktopIcon
2422 2422 }
2423 2423 }
↓ open down ↓ |
2360 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX