2002/04/30 21:16:33
[org.ibex.core.git] / src / org / xwt / plat / Java14.java
diff --git a/src/org/xwt/plat/Java14.java b/src/org/xwt/plat/Java14.java
new file mode 100644 (file)
index 0000000..cd90e8c
--- /dev/null
@@ -0,0 +1,58 @@
+// Copyright 2002 Adam Megacz, see the COPYING file for licensing [GPL]
+package org.xwt.plat;
+
+import java.awt.*;
+import java.awt.event.*;
+import java.awt.image.*;
+import java.awt.datatransfer.*;
+import java.net.*;
+import java.io.*;
+import java.util.*;
+import org.xwt.util.*;
+import org.xwt.*;
+
+/** Platform class for most reasonable Java1.4+ JVMs */
+public class Java14 extends Java12 {
+
+    protected String getDescriptiveName() { return "Java 1.4+ JVM"; }
+    protected boolean _supressDirtyOnResize() { return false; }
+
+    public Java14() {
+        java.awt.Toolkit.getDefaultToolkit().setDynamicLayout(true);
+    }
+
+    protected Surface _createSurface(final Box root, final boolean framed) {
+        return (Surface)java.security.AccessController.doPrivileged(new java.security.PrivilegedAction() {
+                public Object run() { return new Java14Surface(root, framed); }
+            });
+    }
+
+    protected static class Java14Surface extends Java12Surface implements WindowStateListener {
+        public Java14Surface(Box root, boolean framed) {
+            super(root, framed);
+            window.addWindowStateListener(this);
+        }
+        protected void _setMaximized(boolean m) {
+            if (frame == null) {
+                if (Log.on) Log.log(this, "JDK 1.4 can only maximize frames, not windows");
+                return;
+            }
+            frame.setExtendedState(m ? Frame.MAXIMIZED_BOTH : (minimized ? Frame.ICONIFIED : Frame.NORMAL));
+        }
+        protected void _setMinimized(boolean m) {
+            if (frame == null) {
+                if (Log.on) Log.log(this, "JDK 1.4 can only minimize frames, not windows");
+                return;
+            }
+            frame.setExtendedState(m ? Frame.ICONIFIED : (maximized ? Frame.MAXIMIZED_BOTH : Frame.NORMAL));
+        }
+        public void windowStateChanged(WindowEvent e) {
+            if (e.getOldState() != e.getNewState()) {
+                if ((e.getNewState() & Frame.MAXIMIZED_BOTH) != 0) Maximized(true);
+                else if (((e.getOldState() & Frame.MAXIMIZED_BOTH) != 0) && (e.getNewState() & Frame.MAXIMIZED_BOTH) == 0)
+                    Maximized(false);
+            }
+        }
+    }
+        
+}