cd90e8cd5aa9272997a5419a91498fb8914bc655
[org.ibex.core.git] / src / org / xwt / plat / Java14.java
1 // Copyright 2002 Adam Megacz, see the COPYING file for licensing [GPL]
2 package org.xwt.plat;
3
4 import java.awt.*;
5 import java.awt.event.*;
6 import java.awt.image.*;
7 import java.awt.datatransfer.*;
8 import java.net.*;
9 import java.io.*;
10 import java.util.*;
11 import org.xwt.util.*;
12 import org.xwt.*;
13
14 /** Platform class for most reasonable Java1.4+ JVMs */
15 public class Java14 extends Java12 {
16
17     protected String getDescriptiveName() { return "Java 1.4+ JVM"; }
18     protected boolean _supressDirtyOnResize() { return false; }
19
20     public Java14() {
21         java.awt.Toolkit.getDefaultToolkit().setDynamicLayout(true);
22     }
23
24     protected Surface _createSurface(final Box root, final boolean framed) {
25         return (Surface)java.security.AccessController.doPrivileged(new java.security.PrivilegedAction() {
26                 public Object run() { return new Java14Surface(root, framed); }
27             });
28     }
29
30     protected static class Java14Surface extends Java12Surface implements WindowStateListener {
31         public Java14Surface(Box root, boolean framed) {
32             super(root, framed);
33             window.addWindowStateListener(this);
34         }
35         protected void _setMaximized(boolean m) {
36             if (frame == null) {
37                 if (Log.on) Log.log(this, "JDK 1.4 can only maximize frames, not windows");
38                 return;
39             }
40             frame.setExtendedState(m ? Frame.MAXIMIZED_BOTH : (minimized ? Frame.ICONIFIED : Frame.NORMAL));
41         }
42         protected void _setMinimized(boolean m) {
43             if (frame == null) {
44                 if (Log.on) Log.log(this, "JDK 1.4 can only minimize frames, not windows");
45                 return;
46             }
47             frame.setExtendedState(m ? Frame.ICONIFIED : (maximized ? Frame.MAXIMIZED_BOTH : Frame.NORMAL));
48         }
49         public void windowStateChanged(WindowEvent e) {
50             if (e.getOldState() != e.getNewState()) {
51                 if ((e.getNewState() & Frame.MAXIMIZED_BOTH) != 0) Maximized(true);
52                 else if (((e.getOldState() & Frame.MAXIMIZED_BOTH) != 0) && (e.getNewState() & Frame.MAXIMIZED_BOTH) == 0)
53                     Maximized(false);
54             }
55         }
56     }
57         
58 }