jdk/src/java.desktop/share/classes/javax/swing/JFrame.java
changeset 29511 7c491ff8a5fc
parent 28231 b608ffcaed74
child 30933 03b018d18b52
equal deleted inserted replaced
29510:9c567246bdae 29511:7c491ff8a5fc
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.  Oracle designates this
     7  * published by the Free Software Foundation.  Oracle designates this
   126                                               Accessible,
   126                                               Accessible,
   127                                               RootPaneContainer,
   127                                               RootPaneContainer,
   128                               TransferHandler.HasGetTransferHandler
   128                               TransferHandler.HasGetTransferHandler
   129 {
   129 {
   130     /**
   130     /**
   131      * The exit application default window close operation. If a window
       
   132      * has this set as the close operation and is closed in an applet,
       
   133      * a <code>SecurityException</code> may be thrown.
       
   134      * It is recommended you only use this in an application.
       
   135      *
       
   136      * @since 1.3
       
   137      */
       
   138     public static final int EXIT_ON_CLOSE = 3;
       
   139 
       
   140     /**
       
   141      * Key into the AppContext, used to check if should provide decorations
   131      * Key into the AppContext, used to check if should provide decorations
   142      * by default.
   132      * by default.
   143      */
   133      */
   144     private static final Object defaultLookAndFeelDecoratedKey =
   134     private static final Object defaultLookAndFeelDecoratedKey =
   145             new StringBuffer("JFrame.defaultLookAndFeelDecorated");
   135             new StringBuffer("JFrame.defaultLookAndFeelDecorated");
   350      * Automatically hide and dispose the
   340      * Automatically hide and dispose the
   351      * frame after invoking any registered <code>WindowListener</code>
   341      * frame after invoking any registered <code>WindowListener</code>
   352      * objects.
   342      * objects.
   353      *
   343      *
   354      * <li><code>EXIT_ON_CLOSE</code>
   344      * <li><code>EXIT_ON_CLOSE</code>
   355      * (defined in <code>JFrame</code>):
   345      * (defined in <code>WindowConstants</code>):
   356      * Exit the application using the <code>System</code>
   346      * Exit the application using the <code>System</code>
   357      * <code>exit</code> method.  Use this only in applications.
   347      * <code>exit</code> method.  Use this only in applications.
   358      * </ul>
   348      * </ul>
   359      * <p>
   349      * <p>
   360      * The value is set to <code>HIDE_ON_CLOSE</code> by default. Changes
   350      * The value is set to <code>HIDE_ON_CLOSE</code> by default. Changes
   391     public void setDefaultCloseOperation(int operation) {
   381     public void setDefaultCloseOperation(int operation) {
   392         if (operation != DO_NOTHING_ON_CLOSE &&
   382         if (operation != DO_NOTHING_ON_CLOSE &&
   393             operation != HIDE_ON_CLOSE &&
   383             operation != HIDE_ON_CLOSE &&
   394             operation != DISPOSE_ON_CLOSE &&
   384             operation != DISPOSE_ON_CLOSE &&
   395             operation != EXIT_ON_CLOSE) {
   385             operation != EXIT_ON_CLOSE) {
   396             throw new IllegalArgumentException("defaultCloseOperation must be one of: DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE, DISPOSE_ON_CLOSE, or EXIT_ON_CLOSE");
   386             throw new IllegalArgumentException("defaultCloseOperation must be"
       
   387                     + " one of: DO_NOTHING_ON_CLOSE, HIDE_ON_CLOSE,"
       
   388                     + " DISPOSE_ON_CLOSE, or EXIT_ON_CLOSE");
   397         }
   389         }
   398 
   390 
   399         if (operation == EXIT_ON_CLOSE) {
   391         if (operation == EXIT_ON_CLOSE) {
   400             SecurityManager security = System.getSecurityManager();
   392             SecurityManager security = System.getSecurityManager();
   401             if (security != null) {
   393             if (security != null) {
   859             defaultCloseOperationString = "HIDE_ON_CLOSE";
   851             defaultCloseOperationString = "HIDE_ON_CLOSE";
   860         } else if (defaultCloseOperation == DISPOSE_ON_CLOSE) {
   852         } else if (defaultCloseOperation == DISPOSE_ON_CLOSE) {
   861             defaultCloseOperationString = "DISPOSE_ON_CLOSE";
   853             defaultCloseOperationString = "DISPOSE_ON_CLOSE";
   862         } else if (defaultCloseOperation == DO_NOTHING_ON_CLOSE) {
   854         } else if (defaultCloseOperation == DO_NOTHING_ON_CLOSE) {
   863             defaultCloseOperationString = "DO_NOTHING_ON_CLOSE";
   855             defaultCloseOperationString = "DO_NOTHING_ON_CLOSE";
   864         } else if (defaultCloseOperation == 3) {
   856         } else if (defaultCloseOperation == EXIT_ON_CLOSE) {
   865             defaultCloseOperationString = "EXIT_ON_CLOSE";
   857             defaultCloseOperationString = "EXIT_ON_CLOSE";
   866         } else defaultCloseOperationString = "";
   858         } else defaultCloseOperationString = "";
   867         String rootPaneString = (rootPane != null ?
   859         String rootPaneString = (rootPane != null ?
   868                                  rootPane.toString() : "");
   860                                  rootPane.toString() : "");
   869         String rootPaneCheckingEnabledString = (rootPaneCheckingEnabled ?
   861         String rootPaneCheckingEnabledString = (rootPaneCheckingEnabled ?