GNU Classpath (0.19) | ||
Frames | No Frames |
1: /* JInternalFrame.java -- 2: Copyright (C) 2002, 2004, 2005 Free Software Foundation, Inc. 3: 4: This file is part of GNU Classpath. 5: 6: GNU Classpath is free software; you can redistribute it and/or modify 7: it under the terms of the GNU General Public License as published by 8: the Free Software Foundation; either version 2, or (at your option) 9: any later version. 10: 11: GNU Classpath is distributed in the hope that it will be useful, but 12: WITHOUT ANY WARRANTY; without even the implied warranty of 13: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14: General Public License for more details. 15: 16: You should have received a copy of the GNU General Public License 17: along with GNU Classpath; see the file COPYING. If not, write to the 18: Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 19: 02110-1301 USA. 20: 21: Linking this library statically or dynamically with other modules is 22: making a combined work based on this library. Thus, the terms and 23: conditions of the GNU General Public License cover the whole 24: combination. 25: 26: As a special exception, the copyright holders of this library give you 27: permission to link this library with independent modules to produce an 28: executable, regardless of the license terms of these independent 29: modules, and to copy and distribute the resulting executable under 30: terms of your choice, provided that you also meet, for each linked 31: independent module, the terms and conditions of the license of that 32: module. An independent module is a module which is not derived from 33: or based on this library. If you modify this library, you may extend 34: this exception to your version of the library, but you are not 35: obligated to do so. If you do not wish to do so, delete this 36: exception statement from your version. */ 37: 38: 39: package javax.swing; 40: 41: import java.awt.Component; 42: import java.awt.Container; 43: import java.awt.Graphics; 44: import java.awt.KeyboardFocusManager; 45: import java.awt.LayoutManager; 46: import java.awt.Rectangle; 47: import java.beans.PropertyVetoException; 48: 49: import javax.accessibility.Accessible; 50: import javax.accessibility.AccessibleContext; 51: import javax.accessibility.AccessibleRole; 52: import javax.accessibility.AccessibleValue; 53: import javax.swing.event.InternalFrameEvent; 54: import javax.swing.event.InternalFrameListener; 55: import javax.swing.plaf.DesktopIconUI; 56: import javax.swing.plaf.InternalFrameUI; 57: 58: /** 59: * This class implements a Swing widget that looks and acts like a native 60: * frame. The frame can be dragged, resized, closed, etc. Typically, 61: * JInternalFrames are placed in JDesktopPanes. The actions that the 62: * JInternalFrame performs (maximizing, minimizing, etc.) are performed by a 63: * DesktopManager. As with regular frames, components are added by calling 64: * frame.getContentPane().add. 65: */ 66: public class JInternalFrame extends JComponent implements Accessible, 67: WindowConstants, 68: RootPaneContainer 69: { 70: /** DOCUMENT ME! */ 71: private static final long serialVersionUID = -5425177187760785402L; 72: 73: /** 74: * DOCUMENT ME! 75: */ 76: protected class AccessibleJInternalFrame extends AccessibleJComponent 77: implements AccessibleValue 78: { 79: private static final long serialVersionUID = 5931936924175476797L; 80: 81: /** 82: * Creates a new AccessibleJInternalFrame object. 83: */ 84: protected AccessibleJInternalFrame() 85: { 86: super(); 87: } 88: 89: /** 90: * DOCUMENT ME! 91: * 92: * @return DOCUMENT ME! 93: */ 94: public String getAccessibleName() 95: { 96: return null; 97: } 98: 99: /** 100: * DOCUMENT ME! 101: * 102: * @return DOCUMENT ME! 103: */ 104: public AccessibleRole getAccessibleRole() 105: { 106: return null; 107: } 108: 109: /** 110: * DOCUMENT ME! 111: * 112: * @return DOCUMENT ME! 113: */ 114: public AccessibleValue getAccessibleValue() 115: { 116: return null; 117: } 118: 119: /** 120: * DOCUMENT ME! 121: * 122: * @return DOCUMENT ME! 123: */ 124: public Number getCurrentAccessibleValue() 125: { 126: return null; 127: } 128: 129: /** 130: * DOCUMENT ME! 131: * 132: * @return DOCUMENT ME! 133: */ 134: public Number getMaximumAccessibleValue() 135: { 136: return null; 137: } 138: 139: /** 140: * DOCUMENT ME! 141: * 142: * @return DOCUMENT ME! 143: */ 144: public Number getMinimumAccessibleValue() 145: { 146: return null; 147: } 148: 149: /** 150: * DOCUMENT ME! 151: * 152: * @param n DOCUMENT ME! 153: * 154: * @return DOCUMENT ME! 155: */ 156: public boolean setCurrentAccessibleValue(Number n) 157: { 158: return false; 159: } 160: } 161: 162: /** 163: * This class represents the JInternalFrame while it is iconified. 164: */ 165: public static class JDesktopIcon extends JComponent implements Accessible 166: { 167: /** 168: * DOCUMENT ME! 169: */ 170: protected class AccessibleJDesktopIcon extends AccessibleJComponent 171: implements AccessibleValue 172: { 173: private static final long serialVersionUID = 5035560458941637802L; 174: 175: /** 176: * Creates a new AccessibleJDesktopIcon object. 177: */ 178: protected AccessibleJDesktopIcon() 179: { 180: super(); 181: } 182: 183: /** 184: * DOCUMENT ME! 185: * 186: * @return DOCUMENT ME! 187: */ 188: public AccessibleRole getAccessibleRole() 189: { 190: return null; 191: } 192: 193: /** 194: * DOCUMENT ME! 195: * 196: * @return DOCUMENT ME! 197: */ 198: public AccessibleValue getAccessibleValue() 199: { 200: return null; 201: } 202: 203: /** 204: * DOCUMENT ME! 205: * 206: * @return DOCUMENT ME! 207: */ 208: public Number getCurrentAccessibleValue() 209: { 210: return null; 211: } 212: 213: /** 214: * DOCUMENT ME! 215: * 216: * @return DOCUMENT ME! 217: */ 218: public Number getMaximumAccessibleValue() 219: { 220: return null; 221: } 222: 223: /** 224: * DOCUMENT ME! 225: * 226: * @return DOCUMENT ME! 227: */ 228: public Number getMinimumAccessibleValue() 229: { 230: return null; 231: } 232: 233: /** 234: * DOCUMENT ME! 235: * 236: * @param n DOCUMENT ME! 237: * 238: * @return DOCUMENT ME! 239: */ 240: public boolean setCurrentAccessibleValue(Number n) 241: { 242: return false; 243: } 244: } 245: 246: private static final long serialVersionUID = 4672973344731387687L; 247: 248: /** The JInternalFrame this DesktopIcon represents. */ 249: JInternalFrame frame; 250: 251: /** 252: * Creates a new JDesktopIcon object for representing the given frame. 253: * 254: * @param f The JInternalFrame to represent. 255: */ 256: public JDesktopIcon(JInternalFrame f) 257: { 258: frame = f; 259: updateUI(); 260: } 261: 262: /** 263: * DOCUMENT ME! 264: * 265: * @return DOCUMENT ME! 266: */ 267: public AccessibleContext getAccessibleContext() 268: { 269: if (accessibleContext == null) 270: accessibleContext = new AccessibleJDesktopIcon(); 271: return accessibleContext; 272: } 273: 274: /** 275: * This method returns the JDesktopPane this JDesktopIcon is in. 276: * 277: * @return The JDesktopPane this JDesktopIcon is in. 278: */ 279: public JDesktopPane getDesktopPane() 280: { 281: JDesktopPane p = (JDesktopPane) SwingUtilities.getAncestorOfClass(JDesktopPane.class, 282: this); 283: return p; 284: } 285: 286: /** 287: * This method returns the JInternalFrame this JDesktopIcon represents. 288: * 289: * @return The JInternalFrame this JDesktopIcon represents. 290: */ 291: public JInternalFrame getInternalFrame() 292: { 293: return frame; 294: } 295: 296: /** 297: * This method returns the UI that is responsible for the JDesktopIcon. 298: * 299: * @return The UI that is responsible for the JDesktopIcon. 300: */ 301: public DesktopIconUI getUI() 302: { 303: return (DesktopIconUI) ui; 304: } 305: 306: /** 307: * This method returns the String identifier that is used to determine 308: * which class is used for JDesktopIcon's UI. 309: * 310: * @return A String identifier for the UI class. 311: */ 312: public String getUIClassID() 313: { 314: return "DesktopIconUI"; 315: } 316: 317: /** 318: * This method sets the JInternalFrame that this JDesktopIcon represents. 319: * 320: * @param f The JInternalFrame that this JDesktopIcon represents. 321: */ 322: public void setInternalFrame(JInternalFrame f) 323: { 324: frame = f; 325: } 326: 327: /** 328: * This method sets the UI used for this JDesktopIcon. 329: * 330: * @param ui The UI to use. 331: */ 332: public void setUI(DesktopIconUI ui) 333: { 334: super.setUI(ui); 335: } 336: 337: /** 338: * This method restores the UI property to the defaults. 339: */ 340: public void updateUI() 341: { 342: setUI((DesktopIconUI) UIManager.getUI(this)); 343: } 344: } 345: 346: /** 347: * The property fired in a PropertyChangeEvent when the contentPane property 348: * changes. 349: */ 350: public static final String CONTENT_PANE_PROPERTY = "contentPane"; 351: 352: /** 353: * The property fired in a PropertyChangeEvent when the frameIcon property 354: * changes. 355: */ 356: public static final String FRAME_ICON_PROPERTY = "frameIcon"; 357: 358: /** 359: * The property fired in a PropertyChangeEvent when the glassPane property 360: * changes. 361: */ 362: public static final String GLASS_PANE_PROPERTY = "glassPane"; 363: 364: /** 365: * The property fired in a PropertyChangeEvent when the closed property 366: * changes. 367: */ 368: public static final String IS_CLOSED_PROPERTY = "closed"; 369: 370: /** 371: * The property fired in a PropertyChangeEvent when the icon property 372: * changes. 373: */ 374: public static final String IS_ICON_PROPERTY = "icon"; 375: 376: /** 377: * The property fired in a PropertyChangeEvent when the maximum property 378: * changes. 379: */ 380: public static final String IS_MAXIMUM_PROPERTY = "maximum"; 381: 382: /** 383: * The property fired in a PropertyChangeEvent when the selected property 384: * changes. 385: */ 386: public static final String IS_SELECTED_PROPERTY = "selected"; 387: 388: /** 389: * The property fired in a PropertyChangeEvent when the layeredPane property 390: * changes. 391: */ 392: public static final String LAYERED_PANE_PROPERTY = "layeredPane"; 393: 394: /** 395: * The property fired in a PropertyChangeEvent when the jMenuBar property 396: * changes. 397: */ 398: public static final String MENU_BAR_PROPERTY = "JMenuBar"; 399: 400: /** 401: * The property fired in a PropertyChangeEvent when the rootPane property 402: * changes. 403: */ 404: public static final String ROOT_PANE_PROPERTY = "rootPane"; 405: 406: /** 407: * The property fired in a PropertyChangeEvent when the title property 408: * changes. 409: */ 410: public static final String TITLE_PROPERTY = "title"; 411: 412: /** Whether the JInternalFrame is closable. */ 413: protected boolean closable; 414: 415: /** Whether the JInternalFrame can be iconified. */ 416: protected boolean iconable; 417: 418: /** Whether the JInternalFrame is closed. */ 419: protected boolean isClosed; 420: 421: /** Whether the JInternalFrame has been iconified. */ 422: protected boolean isIcon; 423: 424: /** Whether the JInternalFrame has been maximized. */ 425: protected boolean isMaximum; 426: 427: /** Whether the JInternalFrame is the active frame. */ 428: protected boolean isSelected; 429: 430: /** Whether the JInternalFrame can be maximized. */ 431: protected boolean maximizable; 432: 433: /** 434: * Whether the JInternalFrame has rootPaneChecking enabled. 435: * 436: * @specnote Should be false to comply with J2SE 5.0 437: */ 438: protected boolean rootPaneCheckingEnabled = false; 439: 440: /** 441: * Tells us if we're in the initialization stage. 442: * If so, adds go to top-level Container, otherwise they go 443: * to the content pane for this container. 444: */ 445: private boolean initStageDone = false; 446: 447: /** Whether the JInternalFrame is resizable. */ 448: protected boolean resizable; 449: 450: /** 451: * The JDesktopIcon that represents the JInternalFrame while it is 452: * iconified. 453: */ 454: protected JDesktopIcon desktopIcon; 455: 456: /** The icon used in the JMenuBar in the TitlePane. */ 457: protected Icon frameIcon; 458: 459: /** The rootPane of the JInternalFrame. */ 460: protected JRootPane rootPane; 461: 462: /** The title on the TitlePane of the JInternalFrame. */ 463: protected String title; 464: 465: /** The bounds of the JInternalFrame before it was maximized. */ 466: private transient Rectangle storedBounds; 467: 468: /** The Component that receives focus by default. */ 469: private transient Component defaultFocus; 470: 471: /** The default close action taken, */ 472: private transient int defaultCloseOperation = DISPOSE_ON_CLOSE; 473: 474: /** Whether the JInternalFrame has become visible for the very first time. */ 475: private transient boolean isFirstTimeVisible = true; 476: 477: /** 478: * Whether the JInternalFrame is in the transition from being a maximized 479: * frame back to a regular sized frame. 480: */ 481: private transient boolean maxTransition = false; 482: 483: /** DOCUMENT ME! */ 484: private transient boolean wasIcon = false; 485: 486: /** 487: * Creates a new JInternalFrame object that has no title, and is 488: * non-resizable, non-maximizable, non-iconifiable, and non-closable. 489: */ 490: public JInternalFrame() 491: { 492: this(null, false, false, false, false); 493: } 494: 495: /** 496: * Creates a new JInternalFrame object with the given title and is 497: * non-resizable, non-maximizable, non-iconifiable, and non-closable. 498: * 499: * @param title The title displayed in the JInternalFrame. 500: */ 501: public JInternalFrame(String title) 502: { 503: this(title, false, false, false, false); 504: } 505: 506: /** 507: * Creates a new JInternalFrame object with the given title and resizable 508: * properties. The JInternalFrame is non-maximizable, non-iconifiable, and 509: * non-closable. 510: * 511: * @param title The title displayed in the JInternalFrame. 512: * @param resizable Whether the JInternalFrame is resizable. 513: */ 514: public JInternalFrame(String title, boolean resizable) 515: { 516: this(title, resizable, false, false, false); 517: } 518: 519: /** 520: * Creates a new JInternalFrame object with the given title, resizable, and 521: * closable properties. The JInternalFrame is non-maximizable and 522: * non-iconifiable. 523: * 524: * @param title The title displayed in the JInternalFrame. 525: * @param resizable Whether the JInternalFrame is resizable. 526: * @param closable Whether the JInternalFrame is closable. 527: */ 528: public JInternalFrame(String title, boolean resizable, boolean closable) 529: { 530: this(title, resizable, closable, false, false); 531: } 532: 533: /** 534: * Creates a new JInternalFrame object with the given title, resizable, 535: * closable and maximizable properties. The JInternalFrame is 536: * non-iconifiable. 537: * 538: * @param title The title displayed in the JInternalFrame. 539: * @param resizable Whether the JInternalFrame is resizable. 540: * @param closable Whether the JInternalFrame is closable. 541: * @param maximizable Whether the JInternalFrame is maximizable. 542: */ 543: public JInternalFrame(String title, boolean resizable, boolean closable, 544: boolean maximizable) 545: { 546: this(title, resizable, closable, maximizable, false); 547: } 548: 549: /** 550: * Creates a new JInternalFrame object with the given title, resizable, 551: * closable, maximizable and iconifiable properties. 552: * 553: * @param title The title displayed in the JInternalFrame. 554: * @param resizable Whether the JInternalFrame is resizable. 555: * @param closable Whether the JInternalFrame is closable. 556: * @param maximizable Whether the JInternalFrame is maximizable. 557: * @param iconifiable Whether the JInternalFrame is iconifiable. 558: */ 559: public JInternalFrame(String title, boolean resizable, boolean closable, 560: boolean maximizable, boolean iconifiable) 561: { 562: this.title = title; 563: this.resizable = resizable; 564: this.closable = closable; 565: this.maximizable = maximizable; 566: this.iconable = iconifiable; 567: storedBounds = new Rectangle(); 568: setRootPane(createRootPane()); 569: updateUI(); 570: initStageDone = true; // Done the init stage, now adds go to content pane. 571: } 572: 573: /** 574: * This method adds Components to this Container. For JInternalFrames, 575: * instead of calling add directly on the JInternalFrame, it should be 576: * called with JInternalFrame.getContentPane().add. If root pane checking 577: * is enabled, calling this method will cause an exception to be thrown. 578: * 579: * @param comp The Component to add. 580: * @param constraints The constraints on the Component added. 581: * @param index The position to place the Component. 582: * 583: * @throws Error DOCUMENT ME! 584: */ 585: protected void addImpl(Component comp, Object constraints, int index) 586: { 587: // If we're in the initialization stage use super.add. Here we add the 588: // rootPane as well as the title bar and other stuff. 589: // Otherwise pass the add onto the content pane. 590: if (!initStageDone) 591: super.addImpl(comp,constraints, index); 592: else 593: { 594: if (isRootPaneCheckingEnabled()) 595: throw new Error("Do not use add() on JInternalFrame directly. Use " 596: + "getContentPane().add() instead"); 597: getContentPane().add(comp, constraints, index); 598: } 599: } 600: 601: /** 602: * This method adds an InternalFrameListener to this JInternalFrame. 603: * 604: * @param l The listener to add. 605: */ 606: public void addInternalFrameListener(InternalFrameListener l) 607: { 608: listenerList.add(InternalFrameListener.class, l); 609: } 610: 611: /** 612: * This method is used to create a root pane for the JInternalFrame. This 613: * method is called by the constructors. 614: * 615: * @return A root pane for the JInternalFrame to use. 616: */ 617: protected JRootPane createRootPane() 618: { 619: return new JRootPane(); 620: } 621: 622: /** 623: * This method makes this JInternalFrame invisible, unselected and closed. 624: * If this JInternalFrame is not closed already, it will fire an 625: * INTERNAL_FRAME_CLoSED event. This method is similar to setClosed but it 626: * doesn't give vetoable listeners a chance to veto and it will not fire an 627: * INTERNAL_FRAME_CLOSING event. 628: */ 629: public void dispose() 630: { 631: hide(); 632: JDesktopPane pane = getDesktopPane(); 633: if (pane != null) 634: pane.setSelectedFrame(null); 635: else 636: { 637: try 638: { 639: setSelected(false); 640: } 641: catch (PropertyVetoException e) 642: { 643: // Do nothing if they don't want to be unselected. 644: } 645: } 646: isClosed = true; 647: fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_CLOSED); 648: removeNotify(); 649: } 650: 651: /** 652: * This method is used for closing this JInternalFrame. It fires an 653: * INTERNAL_FRAME_CLOSING event and then performs the action specified by 654: * the default close operation. 655: */ 656: public void doDefaultCloseAction() 657: { 658: fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_CLOSING); 659: switch (getDefaultCloseOperation()) 660: { 661: case HIDE_ON_CLOSE: 662: hide(); 663: break; 664: case DISPOSE_ON_CLOSE: 665: dispose(); 666: break; 667: } 668: } 669: 670: /** 671: * This method fires an InternalFrameEvent to the listeners. 672: * 673: * @param id The type of event being fired. See InternalFrameEvent. 674: */ 675: protected void fireInternalFrameEvent(int id) 676: { 677: Object[] ifListeners = listenerList.getListenerList(); 678: InternalFrameEvent evt = new InternalFrameEvent(this, id); 679: switch (id) 680: { 681: case InternalFrameEvent.INTERNAL_FRAME_CLOSING: 682: for (int i = ifListeners.length - 2; i >= 0; i -= 2) 683: { 684: if (ifListeners[i] == InternalFrameListener.class) 685: ((InternalFrameListener) ifListeners[i + 1]) 686: .internalFrameClosing(evt); 687: } 688: break; 689: case InternalFrameEvent.INTERNAL_FRAME_ACTIVATED: 690: for (int i = ifListeners.length - 2; i >= 0; i -= 2) 691: { 692: if (ifListeners[i] == InternalFrameListener.class) 693: ((InternalFrameListener) ifListeners[i + 1]) 694: .internalFrameActivated(evt); 695: } 696: break; 697: case InternalFrameEvent.INTERNAL_FRAME_CLOSED: 698: for (int i = ifListeners.length - 2; i >= 0; i -= 2) 699: { 700: if (ifListeners[i] == InternalFrameListener.class) 701: ((InternalFrameListener) ifListeners[i + 1]).internalFrameClosed(evt); 702: } 703: break; 704: case InternalFrameEvent.INTERNAL_FRAME_DEACTIVATED: 705: for (int i = ifListeners.length - 2; i >= 0; i -= 2) 706: { 707: if (ifListeners[i] == InternalFrameListener.class) 708: ((InternalFrameListener) ifListeners[i + 1]) 709: .internalFrameDeactivated(evt); 710: } 711: break; 712: case InternalFrameEvent.INTERNAL_FRAME_DEICONIFIED: 713: for (int i = ifListeners.length - 2; i >= 0; i -= 2) 714: { 715: if (ifListeners[i] == InternalFrameListener.class) 716: ((InternalFrameListener) ifListeners[i + 1]) 717: .internalFrameDeiconified(evt); 718: } 719: break; 720: case InternalFrameEvent.INTERNAL_FRAME_ICONIFIED: 721: for (int i = ifListeners.length - 2; i >= 0; i -= 2) 722: { 723: if (ifListeners[i] == InternalFrameListener.class) 724: ((InternalFrameListener) ifListeners[i + 1]) 725: .internalFrameIconified(evt); 726: } 727: break; 728: case InternalFrameEvent.INTERNAL_FRAME_OPENED: 729: for (int i = ifListeners.length - 2; i >= 0; i -= 2) 730: { 731: if (ifListeners[i] == InternalFrameListener.class) 732: ((InternalFrameListener) ifListeners[i + 1]).internalFrameOpened(evt); 733: } 734: break; 735: } 736: } 737: 738: /** 739: * DOCUMENT ME! 740: * 741: * @return DOCUMENT ME! 742: */ 743: public AccessibleContext getAccessibleContext() 744: { 745: if (accessibleContext == null) 746: accessibleContext = new AccessibleJInternalFrame(); 747: return accessibleContext; 748: } 749: 750: /** 751: * This method returns the Content Pane for this JInternalFrame. 752: * 753: * @return The Content Pane for this JInternalFrame. 754: */ 755: public Container getContentPane() 756: { 757: return getRootPane().getContentPane(); 758: } 759: 760: /** 761: * This method returns the default action taken when this JInternalFrame is 762: * closed. 763: * 764: * @return The default action taken when this JInternalFrame is closed. 765: */ 766: public int getDefaultCloseOperation() 767: { 768: return defaultCloseOperation; 769: } 770: 771: /** 772: * This method returns the JDesktopIcon that represents this JInternalFrame 773: * while it is iconified. 774: * 775: * @return The JDesktopIcon that represents this JInternalFrame while it is 776: * iconified. 777: */ 778: public JDesktopIcon getDesktopIcon() 779: { 780: if (desktopIcon == null) 781: desktopIcon = new JDesktopIcon(this); 782: return desktopIcon; 783: } 784: 785: /** 786: * This method searches this JInternalFrame ancestors for an instance of 787: * JDesktopPane. If one is found, it is returned. If none is found, then it 788: * will search the JDesktopIcon for a JDesktopPane. 789: * 790: * @return The JDesktopPane that this JInternalFrame belongs to. 791: */ 792: public JDesktopPane getDesktopPane() 793: { 794: JDesktopPane value = (JDesktopPane) SwingUtilities.getAncestorOfClass(JDesktopPane.class, 795: this); 796: if (value == null && desktopIcon != null) 797: value = desktopIcon.getDesktopPane(); 798: return value; 799: } 800: 801: /** 802: * This method returns null because this must always be the root of a focus 803: * traversal. 804: * 805: * @return always null 806: * 807: * @since 1.4 808: */ 809: public final Container getFocusCycleRootAncestor() 810: { 811: // as defined. 812: return null; 813: } 814: 815: /** 816: * This method returns the child Component that will receive focus if this 817: * JInternalFrame is selected. 818: * 819: * @return The child Component that will receive focus. 820: */ 821: public Component getFocusOwner() 822: { 823: if (isSelected()) 824: { 825: Component focus = KeyboardFocusManager.getCurrentKeyboardFocusManager().getFocusOwner(); 826: if (SwingUtilities.isDescendingFrom(focus, this)) 827: { 828: defaultFocus = focus; 829: return focus; 830: } 831: } 832: return null; 833: } 834: 835: /** 836: * This method returns the Frame Icon (the icon used in the JInternalFrame 837: * TitlePane and iconified frame). 838: * 839: * @return The Frame Icon. 840: */ 841: public Icon getFrameIcon() 842: { 843: return frameIcon; 844: } 845: 846: /** 847: * This method returns the Glass Pane used with this JInternalFrame. 848: * 849: * @return The Glass Pane used with this JInternalFrame. 850: */ 851: public Component getGlassPane() 852: { 853: return getRootPane().getGlassPane(); 854: } 855: 856: /** 857: * This method returns an array of InternalFrameListeners that are listening 858: * to this JInternalFrame. 859: * 860: * @return An array of InternalFrameListeners that are listening to this 861: * JInternalFrame. 862: */ 863: public InternalFrameListener[] getInternalFrameListeners() 864: { 865: return (InternalFrameListener[]) listenerList.getListeners(InternalFrameListener.class); 866: } 867: 868: /** 869: * This method returns the JMenuBar for this JInternalFrame. 870: * 871: * @return The JMenuBar for this JInternalFrame. 872: */ 873: public JMenuBar getJMenuBar() 874: { 875: return getRootPane().getJMenuBar(); 876: } 877: 878: /** 879: * This method returns the layer that this JInternalFrame resides in. 880: * 881: * @return The layer that this JInternalFrame resides in. 882: */ 883: public int getLayer() 884: { 885: JDesktopPane pane = getDesktopPane(); 886: if (pane != null) 887: // The cast here forces the call to the instance method getLayer() 888: // instead of the static method (this would lead to infinite 889: // recursion). 890: return pane.getLayer((Component) this); 891: return -1; 892: } 893: 894: /** 895: * This method returns the LayeredPane for this JInternalFrame. 896: * 897: * @return The LayeredPane for this JInternalFrame. 898: */ 899: public JLayeredPane getLayeredPane() 900: { 901: return getRootPane().getLayeredPane(); 902: } 903: 904: /** 905: * This method is deprecated. This method returns the JMenuBar for this 906: * JInternalFrame. 907: * 908: * @return The JMenuBar for this JInternalFrame. 909: * 910: * @deprecated 1.0.3 911: */ 912: public JMenuBar getMenuBar() 913: { 914: return getJMenuBar(); 915: } 916: 917: /** 918: * This method returns the child Component that will receive focus when the 919: * JInternalFrame is selected. If the JInternalFrame is selected, this 920: * method returns getFocusOwner(). Otherwise, it will return the child 921: * Component that most recently requested focus. If that is null, then the 922: * initial focus Component is returned. If that is null, then the default 923: * focus component is returned. 924: * 925: * @return The most recent focus owner. 926: */ 927: public Component getMostRecentFocusOwner() 928: { 929: if (isSelected()) 930: return getFocusOwner(); 931: else 932: return defaultFocus; 933: } 934: 935: /** 936: * This method returns the bounds of the JInternalFrame if it is not 937: * maximized. If it is maximized, it returns the bounds of the 938: * JInternalFrame before it was maximized (the bounds that it will be 939: * restored to). 940: * 941: * @return A Rectangle that contains this JInternalFrame's normal bounds (or 942: * just its bounds if it is not maximized). 943: */ 944: public Rectangle getNormalBounds() 945: { 946: if (! isMaximum() && ! maxTransition) 947: return getBounds(); 948: else 949: return storedBounds; 950: } 951: 952: /** 953: * This method returns the Root Pane for this JInternalFrame. 954: * 955: * @return The Root Pane for this JInternalFrame. 956: */ 957: public JRootPane getRootPane() 958: { 959: return rootPane; 960: } 961: 962: /** 963: * This method sets the title of the JInternalFrame. 964: * 965: * @return The String displayed in the TitlePane of this JInternalFrame. 966: */ 967: public String getTitle() 968: { 969: return title; 970: } 971: 972: /** 973: * This method returns the UI used to represent the JInternalFrame. 974: * 975: * @return The UI used to represent the JInternalFrame. 976: */ 977: public InternalFrameUI getUI() 978: { 979: return (InternalFrameUI) ui; 980: } 981: 982: /** 983: * This method returns a String identifier that is used to determine which 984: * class acts as the JInternalFrame's UI. 985: * 986: * @return A String identifier to determine a UI class. 987: */ 988: public String getUIClassID() 989: { 990: return "InternalFrameUI"; 991: } 992: 993: /** 994: * This method returns null. 995: * 996: * @return null. 997: */ 998: public final String getWarningString() 999: { 1000: // as defined. 1001: return null; 1002: } 1003: 1004: /** 1005: * This method deselects this JInternalFrame and hides it. 1006: */ 1007: public void hide() 1008: { 1009: JDesktopPane pane = getDesktopPane(); 1010: if (pane != null) 1011: pane.setSelectedFrame(null); 1012: else 1013: { 1014: try 1015: { 1016: setSelected(false); 1017: } 1018: catch (PropertyVetoException e) 1019: { 1020: // Do nothing. 1021: } 1022: } 1023: super.hide(); 1024: } 1025: 1026: /** 1027: * This method returns whether this JInternalFrame is closable. 1028: * 1029: * @return Whether this JInternalFrame is closable. 1030: */ 1031: public boolean isClosable() 1032: { 1033: return closable; 1034: } 1035: 1036: /** 1037: * This method returns whether this JInternalFrame has been closed. 1038: * 1039: * @return Whether this JInternalFrame is closed. 1040: */ 1041: public boolean isClosed() 1042: { 1043: return isClosed; 1044: } 1045: 1046: /** 1047: * This must always return true. 1048: * 1049: * @return always true 1050: * 1051: * @since 1.4 1052: */ 1053: public final boolean isFocusCycleRoot() 1054: { 1055: return true; 1056: } 1057: 1058: /** 1059: * This method returns whether this JInternalFrame is currently iconified. 1060: * 1061: * @return Whether this JInternalFrame is currently iconified. 1062: */ 1063: public boolean isIcon() 1064: { 1065: return isIcon; 1066: } 1067: 1068: /** 1069: * This method returns whether the JInternalFrame can be iconified. 1070: * 1071: * @return Whether the JInternalFrame can be iconified. 1072: */ 1073: public boolean isIconifiable() 1074: { 1075: return iconable; 1076: } 1077: 1078: /** 1079: * This method returns whether this JInternalFrame can be maximized. 1080: * 1081: * @return Whether this JInternalFrame can be maximized. 1082: */ 1083: public boolean isMaximizable() 1084: { 1085: return maximizable; 1086: } 1087: 1088: /** 1089: * This method returns whether this JInternalFrame is currently maximized. 1090: * 1091: * @return Whether this JInternalFrame is maximized. 1092: */ 1093: public boolean isMaximum() 1094: { 1095: return isMaximum; 1096: } 1097: 1098: /** 1099: * This method returns whether this JInternalFrame is resizable. 1100: * 1101: * @return Whether this JInternalFrame is resizable. 1102: */ 1103: public boolean isResizable() 1104: { 1105: return resizable; 1106: } 1107: 1108: /** 1109: * This method returns whether root pane checking is enabled. If root pane 1110: * checking is enabled, then calls to addImpl and setLayout will throw 1111: * exceptions. 1112: * 1113: * @return Whether root pane checking is enabled. 1114: */ 1115: protected boolean isRootPaneCheckingEnabled() 1116: { 1117: return rootPaneCheckingEnabled; 1118: } 1119: 1120: /** 1121: * This method returns whether this JInternalFrame is selected. 1122: * 1123: * @return Whether this JInternalFrame is selected. 1124: */ 1125: public boolean isSelected() 1126: { 1127: return isSelected; 1128: } 1129: 1130: /** 1131: * A helper method that moves this JInternalFrame to the back if the parent 1132: * is a JLayeredPane. 1133: */ 1134: public void moveToBack() 1135: { 1136: if (getParent() instanceof JLayeredPane) 1137: ((JLayeredPane) getParent()).moveToBack(this); 1138: } 1139: 1140: /** 1141: * A helper method that moves this JInternalFrame to the front if the parent 1142: * is a JLayeredPane. 1143: */ 1144: public void moveToFront() 1145: { 1146: if (getParent() instanceof JLayeredPane) 1147: ((JLayeredPane) getParent()).moveToFront(this); 1148: } 1149: 1150: /** 1151: * This method causes the children of this JInternalFrame to be laid out. 1152: * Before it begins, if this JInternalFrame is an icon, then it will be 1153: * deiconified. If it is maximized, then it will be restored. If either 1154: * operation fails, then this method will return. 1155: */ 1156: public void pack() 1157: { 1158: try 1159: { 1160: if (isIcon()) 1161: setIcon(false); 1162: else if (isMaximum()) 1163: setMaximum(false); 1164: } 1165: catch (PropertyVetoException e) 1166: { 1167: // Do nothing if they don't want to be restored first. 1168: } 1169: setSize(getPreferredSize()); 1170: } 1171: 1172: /** 1173: * This method is overridden to allow for speedier painting while this 1174: * JInternalFramme is being dragged. 1175: * 1176: * @param g The Graphics object to paint with. 1177: */ 1178: protected void paintComponent(Graphics g) 1179: { 1180: super.paintComponent(g); 1181: } 1182: 1183: /** 1184: * This method returns a String describing this JInternalFrame. 1185: * 1186: * @return A String describing this JInternalFrame. 1187: */ 1188: protected String paramString() 1189: { 1190: return "JInternalFrame"; 1191: } 1192: 1193: /** 1194: * This method removes the given Component from the Container. 1195: * 1196: * @param comp The Component to remove. 1197: */ 1198: public void remove(Component comp) 1199: { 1200: // If we're removing the root pane, use super.remove. Otherwise 1201: // pass it on to the content pane instead. 1202: if (comp==rootPane) 1203: super.remove(comp); 1204: else 1205: getContentPane().remove(comp); 1206: } 1207: 1208: /** 1209: * This method removes an InternalFrameListener from this JInternalFrame. 1210: * 1211: * @param l The listener to remove. 1212: */ 1213: public void removeInternalFrameListener(InternalFrameListener l) 1214: { 1215: listenerList.remove(InternalFrameListener.class, l); 1216: } 1217: 1218: /** 1219: * This method resizes and positions this JInternalFrame. It also forces a 1220: * relayout of the Container. 1221: * 1222: * @param x The x position of this JInternalFrame. 1223: * @param y The y position of this JInternalFrame. 1224: * @param width The width of this JInternalFrame. 1225: * @param height The height of this JInternalFrame. 1226: */ 1227: public void reshape(int x, int y, int width, int height) 1228: { 1229: super.reshape(x, y, width, height); 1230: invalidate(); 1231: doLayout(); 1232: } 1233: 1234: /** 1235: * This method gives focus to the last child Component that had focus. This 1236: * is used by the UI when this JInternalFrame is activated. 1237: */ 1238: public void restoreSubcomponentFocus() 1239: { 1240: Component c = getMostRecentFocusOwner(); 1241: if (c != null) 1242: c.requestFocus(); 1243: } 1244: 1245: /** 1246: * This method sets whether this JInternalFrame can be closed. 1247: * 1248: * @param b Whether this JInternalFrame can be closed. 1249: */ 1250: public void setClosable(boolean b) 1251: { 1252: closable = b; 1253: } 1254: 1255: /** 1256: * This method closes the JInternalFrame if the given boolean is true. If it 1257: * is false, then the result of this method is unspecified. If the 1258: * JInternalFrame is closed, this method does nothing. This method will 1259: * first fire an INTERNAL_FRAME_CLOSING event and give a chance for veto 1260: * listeners to cancel the close. If no listener vetoes the change, the 1261: * closed property is set to true and the JInternalFrame is hidden and 1262: * unselected. The method will finish by firing an INTERNAL_FRAME_CLOSED 1263: * event. 1264: * 1265: * @param b Whether the JInternalFrame will be closed. 1266: * 1267: * @throws PropertyVetoException If a VetoableChangeListener vetoes the change. 1268: */ 1269: public void setClosed(boolean b) throws PropertyVetoException 1270: { 1271: if (b && ! isClosed()) 1272: { 1273: fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_CLOSING); 1274: fireVetoableChange(IS_CLOSED_PROPERTY, false, true); 1275: 1276: isClosed = b; 1277: 1278: firePropertyChange(IS_CLOSED_PROPERTY, false, true); 1279: fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_CLOSED); 1280: } 1281: } 1282: 1283: /** 1284: * This method sets the Container to be used as a Content Pane for this 1285: * JInternalFrame. 1286: * 1287: * @param c The Container to use as a Content Pane. 1288: */ 1289: public void setContentPane(Container c) 1290: { 1291: if (c != getContentPane()) 1292: { 1293: Container old = getContentPane(); 1294: getRootPane().setContentPane(c); 1295: firePropertyChange(CONTENT_PANE_PROPERTY, old, c); 1296: } 1297: } 1298: 1299: /** 1300: * This method sets the action taken when this JInternalFrame is closed. 1301: * 1302: * @param operation One of DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE or 1303: * DISPOSE_ON_CLOSE. 1304: * 1305: * @throws Error If the given operation is not one of the allowed modes. 1306: */ 1307: public void setDefaultCloseOperation(int operation) 1308: { 1309: /* Reference implementation allows invalid operations to be specified. 1310: In that case, behaviour defaults to DO_NOTHING_ON_CLOSE. 1311: processWindowEvent handles the behaviour. getDefaultCloseOperation 1312: must return the invalid operator code. */ 1313: defaultCloseOperation = operation; 1314: } 1315: 1316: /** 1317: * This method sets the JDesktopIcon that represents this JInternalFrame 1318: * while it is iconified. 1319: * 1320: * @param d The JDesktopIcon that represents this JInternalFrame while it is 1321: * iconified. 1322: */ 1323: public void setDesktopIcon(JDesktopIcon d) 1324: { 1325: d.setInternalFrame(this); 1326: desktopIcon = d; 1327: } 1328: 1329: /** 1330: * This method does nothing because this must be the root of a focus 1331: * traversal cycle. 1332: * 1333: * @param focusCycleRoot Not used. 1334: */ 1335: public final void setFocusCycleRoot(boolean focusCycleRoot) 1336: { 1337: // Do nothing 1338: } 1339: 1340: /** 1341: * This method sets the Icon to be used in two places. The first is icon 1342: * that is painted at the top left corner of the JInternalFrame when it is 1343: * not iconified (clicking on that icon will activate the TitlePane 1344: * JMenuBar). When the JInternalFrame is iconified, it will be the icon 1345: * displayed in the JDesktopIcon. If no icon is set, the JInternalFrame 1346: * will use a Look and Feel default. 1347: * 1348: * @param icon The Icon used in the TitlePane JMenuBar and iconified frames. 1349: */ 1350: public void setFrameIcon(Icon icon) 1351: { 1352: if (icon != frameIcon) 1353: { 1354: Icon old = frameIcon; 1355: frameIcon = icon; 1356: firePropertyChange(FRAME_ICON_PROPERTY, old, frameIcon); 1357: } 1358: } 1359: 1360: /** 1361: * This method sets the Glass Pane used with this JInternalFrame. 1362: * 1363: * @param glass The Glass Pane to use with this JInternalFrame. 1364: */ 1365: public void setGlassPane(Component glass) 1366: { 1367: if (glass != getGlassPane()) 1368: { 1369: Component old = getGlassPane(); 1370: getRootPane().setGlassPane(glass); 1371: firePropertyChange(GLASS_PANE_PROPERTY, old, glass); 1372: } 1373: } 1374: 1375: /** 1376: * This method iconifies or deiconifies this JInternalFrame given the 1377: * boolean argument. If the JInternalFrame becomes iconified, it will fire 1378: * an INTERNAL_FRAME_ICONIFIED event. If the JInternalFrame becomes 1379: * deiconified, it will fire anINTERNAL_FRAME_DEICONIFIED event. 1380: * 1381: * @param b Whether this JInternalFrame is to be iconified or deiconified. 1382: * 1383: * @throws PropertyVetoException DOCUMENT ME! 1384: */ 1385: public void setIcon(boolean b) throws PropertyVetoException 1386: { 1387: if (b != isIcon()) 1388: { 1389: fireVetoableChange(IS_ICON_PROPERTY, b, isIcon); 1390: 1391: isIcon = b; 1392: 1393: firePropertyChange(IS_ICON_PROPERTY, ! isIcon, isIcon); 1394: if (b) 1395: fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_ICONIFIED); 1396: else 1397: fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_DEICONIFIED); 1398: } 1399: } 1400: 1401: /** 1402: * This method sets whether the JInternalFrame can be iconified. (This means 1403: * that the JInternalFrame can be turned into an icon if minimized). 1404: * 1405: * @param b Whether the JInternalFrame can be iconified. 1406: */ 1407: public void setIconifiable(boolean b) 1408: { 1409: iconable = b; 1410: } 1411: 1412: /** 1413: * This method sets the JMenuBar to be used with this JInternalFrame. 1414: * 1415: * @param b The JMenuBar to be used with this JInternalFrame. 1416: */ 1417: public void setJMenuBar(JMenuBar b) 1418: { 1419: getRootPane().setJMenuBar(b); 1420: } 1421: 1422: /** 1423: * A helper method that set the layer that this JInternalFrame resides in. 1424: * Using this version of the method means that the user should not set it 1425: * to values that are already defined in JLayeredPane. If predefined values 1426: * are to be used, the user should use the setLayer(Integer) version. 1427: * 1428: * @param layer The layer to place this JInternalFrame in. 1429: */ 1430: public void setLayer(int layer) 1431: { 1432: setLayer(new Integer(layer)); 1433: } 1434: 1435: /** 1436: * A helper method that sets the layer that this JInternalFrame resides in. 1437: * Calling this version of the method should use layer values that are 1438: * already defined in JLayeredPane. 1439: * 1440: * @param layer The layer to place this JInternalFrame in. 1441: */ 1442: public void setLayer(Integer layer) 1443: { 1444: JDesktopPane p = getDesktopPane(); 1445: if (p != null) 1446: { 1447: int pos = p.getPosition(this); 1448: p.setLayer(this, layer.intValue(), pos); 1449: } 1450: } 1451: 1452: /** 1453: * This method sets the JLayeredPane to use with this JInternalFrame. 1454: * 1455: * @param layered The JLayeredPane to use as a layeredPane. 1456: */ 1457: public void setLayeredPane(JLayeredPane layered) 1458: { 1459: if (layered != getLayeredPane()) 1460: { 1461: JLayeredPane old = getLayeredPane(); 1462: getRootPane().setLayeredPane(layered); 1463: firePropertyChange(LAYERED_PANE_PROPERTY, old, layered); 1464: } 1465: } 1466: 1467: /** 1468: * This method sets whether the JInternalFrame can be maximized. 1469: * 1470: * @param b Whether this JInternalFrame can be maximized. 1471: */ 1472: public void setMaximizable(boolean b) 1473: { 1474: maximizable = b; 1475: } 1476: 1477: /** 1478: * This method sets the Layout Manager used in the JInternalFrame. SetLayout 1479: * should not be called on the JInternalFrame directly. Instead, it should 1480: * be called with JInternalFrame.getContentPane().setLayout. Calls to this 1481: * method with root pane checking enabled will cause exceptions to be 1482: * thrown. 1483: * 1484: * @param manager The Layout Manager to be used with the JInternalFrame. 1485: * 1486: * @throws Error If rootPaneChecking is enabled. 1487: */ 1488: public void setLayout(LayoutManager manager) 1489: { 1490: // Check if we're in initialization stage. If so, call super.setLayout 1491: // otherwise, valid calls go to the content pane. 1492: if (initStageDone) 1493: { 1494: if (isRootPaneCheckingEnabled()) 1495: throw new Error("Cannot set layout. Use getContentPane().setLayout()" 1496: + " instead."); 1497: getContentPane().setLayout(manager); 1498: } 1499: else 1500: super.setLayout(manager); 1501: } 1502: 1503: /** 1504: * This method sets the JInternalFrame to maximized (if the given argument 1505: * is true) or restores the JInternalFrame to its normal bounds otherwise. 1506: * 1507: * @param b Whether this JInteralFrame will be maximized or restored. 1508: * 1509: * @throws PropertyVetoException If a VetoableChangeListener vetoes the change. 1510: */ 1511: public void setMaximum(boolean b) throws PropertyVetoException 1512: { 1513: if (b != isMaximum()) 1514: { 1515: fireVetoableChange(IS_MAXIMUM_PROPERTY, b, isMaximum); 1516: isMaximum = b; 1517: if (b) 1518: setNormalBounds(getBounds()); 1519: maxTransition = ! b; 1520: firePropertyChange(IS_MAXIMUM_PROPERTY, ! isMaximum, isMaximum); 1521: maxTransition = false; 1522: } 1523: } 1524: 1525: /** 1526: * This method is deprecated. This method sets the JMenuBar used with this 1527: * JInternalFrame. 1528: * 1529: * @param m The JMenuBar to use with this JInternalFrame. 1530: * 1531: * @deprecated 1.0.3 1532: */ 1533: public void setMenuBar(JMenuBar m) 1534: { 1535: setJMenuBar(m); 1536: } 1537: 1538: /** 1539: * This method sets the bounds that this JInternalFrame will be restored to. 1540: * 1541: * @param r The bounds that this JInternalFrame will be restored to. 1542: */ 1543: public void setNormalBounds(Rectangle r) 1544: { 1545: storedBounds.setBounds(r.x, r.y, r.width, r.height); 1546: } 1547: 1548: /** 1549: * This method sets whether the JInternalFrame can be resized by a user 1550: * action (like dragging at the frame borders). 1551: * 1552: * @param b Whether this JInternalFramer can be resized. 1553: */ 1554: public void setResizable(boolean b) 1555: { 1556: resizable = b; 1557: } 1558: 1559: /** 1560: * This method sets the Root Pane for this JInternalFrame. 1561: * 1562: * @param root The Root Pane for this JInternalFrame. 1563: */ 1564: protected void setRootPane(JRootPane root) 1565: { 1566: if (rootPane != null) 1567: remove(rootPane); 1568: 1569: rootPane = root; 1570: add(root); 1571: } 1572: 1573: /** 1574: * This method sets whether root pane checking is enabled. If root pane 1575: * checking is enabled, then calls to addImpl and setLayout will throw 1576: * exceptions. 1577: * 1578: * @param enabled Whether root pane checking is enabled. 1579: */ 1580: protected void setRootPaneCheckingEnabled(boolean enabled) 1581: { 1582: rootPaneCheckingEnabled = enabled; 1583: } 1584: 1585: /** 1586: * This method sets whether this JInternalFrame is the selected frame in the 1587: * JDesktopPane (or other container). When selected, a JInternalFrame will 1588: * have focus and paint its TitlePane differently (usually a different 1589: * colour). If this method selects the frame, this JInternalFrame will fire 1590: * an INTERNAL_FRAME_ACTIVATED event. If it deselects this frame, it will 1591: * fire an INTERNAL_FRAME_DEACTIVATED event. 1592: * 1593: * @param selected Whether this JInternalFrame will become selected or 1594: * deselected. 1595: * 1596: * @throws PropertyVetoException If a VetoableChangeListener vetoes the change. 1597: */ 1598: public void setSelected(boolean selected) throws PropertyVetoException 1599: { 1600: if (selected != isSelected()) 1601: { 1602: fireVetoableChange(IS_SELECTED_PROPERTY, selected, isSelected); 1603: 1604: if (! selected) 1605: defaultFocus = getMostRecentFocusOwner(); 1606: 1607: isSelected = selected; 1608: 1609: if (selected) 1610: restoreSubcomponentFocus(); 1611: 1612: firePropertyChange(IS_SELECTED_PROPERTY, ! isSelected, isSelected); 1613: 1614: if (isSelected) 1615: fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_ACTIVATED); 1616: else 1617: fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_DEACTIVATED); 1618: } 1619: } 1620: 1621: /** 1622: * This method sets the title displayed in the TitlePane of this 1623: * JInternalFrame. 1624: * 1625: * @param title The title displayed. 1626: */ 1627: public void setTitle(String title) 1628: { 1629: if (title == null && this.title == null) 1630: return; 1631: if (title == null || this.title == null || ! this.title.equals(title)) 1632: { 1633: String old = title; 1634: this.title = title; 1635: firePropertyChange(TITLE_PROPERTY, old, this.title); 1636: } 1637: } 1638: 1639: /** 1640: * This method displays the JInternalFrame. If it is not visible, this 1641: * method will bring this JInternalFrame to the front, make it visible and 1642: * select it. If this is the first time this JInternalFrame is made 1643: * visible, an INTERNAL_FRAME_OPENED event will be fired. 1644: */ 1645: public void show() 1646: { 1647: if (! isVisible()) 1648: { 1649: moveToFront(); 1650: super.show(); 1651: 1652: JDesktopPane pane = getDesktopPane(); 1653: if (pane != null) 1654: pane.setSelectedFrame(this); 1655: else 1656: { 1657: try 1658: { 1659: setSelected(true); 1660: } 1661: catch (PropertyVetoException e) 1662: { 1663: // Do nothing. if they don't want to be selected. 1664: } 1665: } 1666: if (isFirstTimeVisible) 1667: { 1668: isFirstTimeVisible = false; 1669: fireInternalFrameEvent(InternalFrameEvent.INTERNAL_FRAME_OPENED); 1670: } 1671: } 1672: } 1673: 1674: /** 1675: * This method is used to set the UI responsible for the JInternalFrame. 1676: * 1677: * @param ui The UI responsible for the JInternalFrame. 1678: */ 1679: public void setUI(InternalFrameUI ui) 1680: { 1681: super.setUI(ui); 1682: } 1683: 1684: /** 1685: * This method causes the JInternalFrame to be brough to back in the 1686: * z-order. 1687: */ 1688: public void toBack() 1689: { 1690: moveToBack(); 1691: } 1692: 1693: /** 1694: * This method causes the JInternalFrame to be brought to front in the 1695: * z-order. 1696: */ 1697: public void toFront() 1698: { 1699: moveToFront(); 1700: } 1701: 1702: /** 1703: * This method resets the UI to the Look and Feel defaults. 1704: */ 1705: public void updateUI() 1706: { 1707: setUI((InternalFrameUI) UIManager.getUI(this)); 1708: } 1709: 1710: /** 1711: * This helper method allows JInternalFrames to signal that they were 1712: * iconned for the first time. 1713: * 1714: * @param b Whether the JInternalFrame was iconned. 1715: * @param ID The identifier of the property change event to fire if the 1716: * JInternalFrame is iconned for the first time. 1717: */ 1718: void setWasIcon(boolean b, String ID) 1719: { 1720: if (b && ! wasIcon) 1721: { 1722: wasIcon = b; 1723: firePropertyChange(ID, ! b, b); 1724: } 1725: } 1726: 1727: /** 1728: * This helper method returns whether the JInternalFrame has been iconned 1729: * once already. 1730: * 1731: * @return Whether the JInternalFrame has been iconned once already. 1732: */ 1733: boolean getWasIcon() 1734: { 1735: return wasIcon; 1736: } 1737: 1738: /** 1739: * This method is a convenience method to fire vetoable property changes. 1740: * 1741: * @param name The identifier of the property change. 1742: * @param oldValue The old value. 1743: * @param newValue The new value. 1744: * 1745: * @throws PropertyVetoException Fired if a vetoable change listener vetoes 1746: * the change. 1747: */ 1748: private void fireVetoableChange(String name, boolean oldValue, 1749: boolean newValue) 1750: throws PropertyVetoException 1751: { 1752: super.fireVetoableChange(name, Boolean.valueOf(oldValue), Boolean.valueOf(newValue)); 1753: } 1754: }
GNU Classpath (0.19) |