16-Aug megacz AWT.java, Java12.java, Java14.java: fixed jdk1.4 bug
               with keypresses and frameless windows.
 
+16-Aug megacz XWT.java, SpecialBoxProperty.java: box.apply()
+
+17-Aug megacz Box.java, SpecialBoxProperty.java, Surface.java: code to
+              prevent engine from quitting when changing the last
+              remaining surface from a frame to a window or vice
+              versa.
+
 
 
 
     /** remove this node from its parent; INVARIANT: whenever the parent of a node is changed, remove() gets called. */
     public void remove() {
         if (parent == null) {
-            if (surface != null) surface.dispose();
+            if (surface != null) surface.dispose(true);
             return;
         }
         Box oldparent = getParent();
 
 
         specialBoxProperties.put("Close", new SpecialBoxProperty() {
                 public void put(Box b, Object value) {
-                    if (b.getParent() == null && b.surface != null) b.surface.dispose();
+                    if (b.getParent() == null && b.surface != null) b.surface.dispose(true);
                 }
             });
 
                     if (Log.on) Log.log(this, "template " + templatename + " not found at " +
                                         Context.enter().interpreterSourceFile + ":" + Context.enter().interpreterLine);
                 } else {
-                    if (!ThreadMessage.suspendThread()) try {
+                    if (ThreadMessage.suspendThread()) try {
                         Function callback = args.length < 2 ? null : (Function)args[1];
                         t.apply(b, null, null, callback, 0, t.numUnits());
                     } finally {
 
     }
 
     /** Indicates that the Surface is no longer needed */
-    public final void dispose() {
+    public final void dispose(boolean quitIfAllSurfacesGone) {
         if (root == null) return;
         if (Log.on) Log.log(this, "disposing " + this);
         allSurfaces.removeElement(this);
         _dispose();
 
         // quit when all windows are closed
-        if (allSurfaces.size() == 0) {
+        if (allSurfaces.size() == 0 && quitIfAllSurfacesGone) {
+            throw new Error();
+            /*
             if (Log.on) {
                 if (refreshableSurfaceWasCreated) Log.log(this, "exiting because last remaining surface was disposed");
                 else Log.log(this, "exiting because no surface was ever created");
             }
             Platform.exit();
+            */
         }
     }
 
         this.scarred = scarAllSurfacesFromNowOn;
         scarAllSurfacesFromNowOn = true;
         this.root = root;
-        if (root.surface != null && root.surface.root == root) root.surface.dispose();
-        root.remove();
+        if (root.surface != null && root.surface.root == root) {
+            root.surface.dispose(false);
+        } else {
+            root.remove();
+        }
         root.setSurface(this);
 
         // make sure the root is properly sized