summaryrefslogtreecommitdiffstats
path: root/libjava/javax/swing/JFrame.java
diff options
context:
space:
mode:
authormkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4>2004-04-21 05:48:51 +0000
committermkoch <mkoch@138bc75d-0d04-0410-961f-82ee72b054a4>2004-04-21 05:48:51 +0000
commit5396b039d610051539b7846b6805ce77883bb2a9 (patch)
tree39e7e83260ed41189cf968ced901bead6477f7fb /libjava/javax/swing/JFrame.java
parentd43633ea40991e4a3e933c25bb512292eb1064d9 (diff)
downloadppe42-gcc-5396b039d610051539b7846b6805ce77883bb2a9.tar.gz
ppe42-gcc-5396b039d610051539b7846b6805ce77883bb2a9.zip
2004-04-21 Mark Wielaard <mark@klomp.org>
* javax/awt/JFrame.java: Implement WindowConstants. Remove final static fields defined in interface. * javax/awt/JDialog.java: Likewise. (JDialog): Make constructors public. (getDefaultCloseOperation): Make public. (processWindowEvent): Call System.exit(0) when EXIT_ON_CLOSE set. (setDefaultCloseOperation): Make public. Check argument. Add API doc. * javax/swing/JViewport.java (JViewport): Make constructor public. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@80945 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libjava/javax/swing/JFrame.java')
-rw-r--r--libjava/javax/swing/JFrame.java43
1 files changed, 30 insertions, 13 deletions
diff --git a/libjava/javax/swing/JFrame.java b/libjava/javax/swing/JFrame.java
index 864f6bae4e0..89d109f660e 100644
--- a/libjava/javax/swing/JFrame.java
+++ b/libjava/javax/swing/JFrame.java
@@ -1,5 +1,5 @@
/* JFrame.java --
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath.
@@ -57,16 +57,11 @@ import javax.accessibility.AccessibleContext;
*
* @author Ronald Veldema (rveldema@cs.vu.nl)
*/
-public class JFrame extends Frame
+public class JFrame extends Frame implements WindowConstants
{
- public final static int HIDE_ON_CLOSE = 0;
- public final static int EXIT_ON_CLOSE = 1;
- public final static int DISPOSE_ON_CLOSE = 2;
- public final static int DO_NOTHING_ON_CLOSE = 3;
-
protected AccessibleContext accessibleContext;
- private int close_action = EXIT_ON_CLOSE;
+ private int close_action = HIDE_ON_CLOSE;
/***************************************************
@@ -192,7 +187,7 @@ public class JFrame extends Frame
return accessibleContext;
}
- int getDefaultCloseOperation()
+ public int getDefaultCloseOperation()
{ return close_action; }
@@ -212,7 +207,7 @@ public class JFrame extends Frame
{
case EXIT_ON_CLOSE:
{
- System.exit(1);
+ System.exit(0);
break;
}
case DISPOSE_ON_CLOSE:
@@ -241,8 +236,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;
+ }
}
OpenPOWER on IntegriCloud