diff options
author | Mark Wielaard <mark@klomp.org> | 2004-04-15 09:35:52 +0000 |
---|---|---|
committer | Mark Wielaard <mark@klomp.org> | 2004-04-15 09:35:52 +0000 |
commit | f4c9d089174c309f8442ed1889b7e1a073c0a29c (patch) | |
tree | 8c47958dd2f778d79c6d138ded48415d28a20488 /javax/swing/JFrame.java | |
parent | 49ed029abc1920c8929d7b1aa4b7bd3e8f53330d (diff) | |
download | classpath-f4c9d089174c309f8442ed1889b7e1a073c0a29c.tar.gz |
* javax/awt/JFrame.java (close_action): Default to HIDE_ON_CLOSE.
(getDefaultCloseOperation): Make public.
(processWindowEvent): Call System.exit(0) when HIDE_ON_CLOSE set.
(setDefaultCloseOperation): Make public. Check argument. Add API doc.
Diffstat (limited to 'javax/swing/JFrame.java')
-rw-r--r-- | javax/swing/JFrame.java | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/javax/swing/JFrame.java b/javax/swing/JFrame.java index 864f6bae4..a2634821f 100644 --- a/javax/swing/JFrame.java +++ b/javax/swing/JFrame.java @@ -66,7 +66,7 @@ public class JFrame extends Frame protected AccessibleContext accessibleContext; - private int close_action = EXIT_ON_CLOSE; + private int close_action = HIDE_ON_CLOSE; /*************************************************** @@ -192,7 +192,7 @@ public class JFrame extends Frame return accessibleContext; } - int getDefaultCloseOperation() + public int getDefaultCloseOperation() { return close_action; } @@ -212,7 +212,7 @@ public class JFrame extends Frame { case EXIT_ON_CLOSE: { - System.exit(1); + System.exit(0); break; } case DISPOSE_ON_CLOSE: @@ -241,8 +241,30 @@ public class JFrame extends Frame } } - - void setDefaultCloseOperation(int operation) - { close_action = operation; } + /** + * Defines what happens when this frame is closed. Can be one off + * <code>EXIT_ON_CLOSE</code>, + * <code>DISPOSE_ON_CLOSE</code>, + * <code>HIDE_ON_CLOSE</code> or + * <code>DO_NOTHING_ON_CLOSE</code>. + * The default is <code>HIDE_ON_CLOSE</code>. + * When <code>EXIT_ON_CLOSE</code> is specified this method calls + * <code>SecurityManager.checkExit(0)</code> which might throw a + * <code>SecurityException</code>. When the specified operation is + * not one of the above a <code>IllegalArgumentException</code> is + * thrown. + */ + public void setDefaultCloseOperation(int operation) + { + SecurityManager sm = System.getSecurityManager(); + if (sm != null && operation == EXIT_ON_CLOSE) + sm.checkExit(0); + + if (operation != EXIT_ON_CLOSE && operation != DISPOSE_ON_CLOSE + && operation != HIDE_ON_CLOSE && operation != DO_NOTHING_ON_CLOSE) + throw new IllegalArgumentException("operation = " + operation); + + close_action = operation; + } } |