Commit 1c3d6bb2 by Mark Wielaard Committed by Michael Koch

JFrame.java: Implement WindowConstants.

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.

From-SVN: r80945
parent 387fa012
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.
2004-04-21 Michael Koch <konqueror@gmx.de> 2004-04-21 Michael Koch <konqueror@gmx.de>
* java/util/Map.java * java/util/Map.java
......
/* JDialog.java -- /* JDialog.java --
Copyright (C) 2002 Free Software Foundation, Inc. Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath. This file is part of GNU Classpath.
...@@ -57,12 +57,8 @@ import javax.accessibility.AccessibleContext; ...@@ -57,12 +57,8 @@ import javax.accessibility.AccessibleContext;
* *
* @author Ronald Veldema (rveldema@cs.vu.nl) * @author Ronald Veldema (rveldema@cs.vu.nl)
*/ */
public class JDialog extends Dialog implements Accessible public class JDialog extends Dialog implements Accessible, WindowConstants
{ {
public final static int HIDE_ON_CLOSE = 0;
public final static int DISPOSE_ON_CLOSE = 1;
public final static int DO_NOTHING_ON_CLOSE = 2;
protected AccessibleContext accessibleContext; protected AccessibleContext accessibleContext;
private int close_action = HIDE_ON_CLOSE; private int close_action = HIDE_ON_CLOSE;
...@@ -75,42 +71,42 @@ public class JDialog extends Dialog implements Accessible ...@@ -75,42 +71,42 @@ public class JDialog extends Dialog implements Accessible
* *
*************/ *************/
JDialog(Frame owner) public JDialog(Frame owner)
{ {
this(owner, "dialog"); this(owner, "dialog");
} }
JDialog(Frame owner, public JDialog(Frame owner,
String s) String s)
{ {
this(owner, s, true); this(owner, s, true);
} }
JDialog(Frame owner, public JDialog(Frame owner,
String s, String s,
boolean modeld) boolean modeld)
{ {
super(owner, s, modeld); super(owner, s, modeld);
} }
JDialog(Frame owner, public JDialog(Frame owner,
// String s, // String s,
boolean modeld) boolean modeld)
{ {
super(owner, "JDialog", modeld); super(owner, "JDialog", modeld);
} }
JDialog(Dialog owner) public JDialog(Dialog owner)
{ {
this(owner, "dialog"); this(owner, "dialog");
} }
JDialog(Dialog owner, public JDialog(Dialog owner,
String s) String s)
{ {
this(owner, s, true); this(owner, s, true);
} }
JDialog(Dialog owner, public JDialog(Dialog owner,
String s, String s,
boolean modeld) boolean modeld)
{ {
...@@ -221,18 +217,20 @@ public class JDialog extends Dialog implements Accessible ...@@ -221,18 +217,20 @@ public class JDialog extends Dialog implements Accessible
protected void processWindowEvent(WindowEvent e) protected void processWindowEvent(WindowEvent e)
{ {
// System.out.println("PROCESS_WIN_EV-1: " + e);
super.processWindowEvent(e); super.processWindowEvent(e);
// System.out.println("PROCESS_WIN_EV-2: " + e);
switch (e.getID()) switch (e.getID())
{ {
case WindowEvent.WINDOW_CLOSING: case WindowEvent.WINDOW_CLOSING:
{ {
switch(close_action) switch(close_action)
{ {
case EXIT_ON_CLOSE:
{
System.exit(0);
break;
}
case DISPOSE_ON_CLOSE: case DISPOSE_ON_CLOSE:
{ {
System.out.println("user requested dispose on close");
dispose(); dispose();
break; break;
} }
...@@ -258,8 +256,34 @@ public class JDialog extends Dialog implements Accessible ...@@ -258,8 +256,34 @@ public class JDialog extends Dialog implements Accessible
} }
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;
}
public int getDefaultCloseOperation()
{ return close_action; }
protected String paramString() protected String paramString()
{ return "JDialog"; } { return "JDialog"; }
......
/* JFrame.java -- /* JFrame.java --
Copyright (C) 2002 Free Software Foundation, Inc. Copyright (C) 2002, 2004 Free Software Foundation, Inc.
This file is part of GNU Classpath. This file is part of GNU Classpath.
...@@ -57,16 +57,11 @@ import javax.accessibility.AccessibleContext; ...@@ -57,16 +57,11 @@ import javax.accessibility.AccessibleContext;
* *
* @author Ronald Veldema (rveldema@cs.vu.nl) * @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; 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 ...@@ -192,7 +187,7 @@ public class JFrame extends Frame
return accessibleContext; return accessibleContext;
} }
int getDefaultCloseOperation() public int getDefaultCloseOperation()
{ return close_action; } { return close_action; }
...@@ -212,7 +207,7 @@ public class JFrame extends Frame ...@@ -212,7 +207,7 @@ public class JFrame extends Frame
{ {
case EXIT_ON_CLOSE: case EXIT_ON_CLOSE:
{ {
System.exit(1); System.exit(0);
break; break;
} }
case DISPOSE_ON_CLOSE: case DISPOSE_ON_CLOSE:
...@@ -241,8 +236,30 @@ public class JFrame extends Frame ...@@ -241,8 +236,30 @@ public class JFrame extends Frame
} }
} }
/**
void setDefaultCloseOperation(int operation) * Defines what happens when this frame is closed. Can be one off
{ close_action = operation; } * <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;
}
} }
...@@ -121,7 +121,7 @@ public class JViewport extends JComponent ...@@ -121,7 +121,7 @@ public class JViewport extends JComponent
Point lastPaintPosition; Point lastPaintPosition;
JViewport() public JViewport()
{ {
setOpaque(true); setOpaque(true);
updateUI(); updateUI();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment