$frame->pack(); } function run() { $this->frame->setVisible(true); } } $swing = new SwingApplication(); $swing->init(); $SwingUtilities = new JavaClass("javax.swing.SwingUtilities"); $SwingUtilities->invokeAndWait(java_closure($swing, null, java("java.lang.Runnable"))); // Due to swings insane design we don't know when the UI thread // terminates. It may even be that the thread and therefore the VM // never terminates, for example if a PrinterJob has been created on // solaris, see the extensive number of related swing bugs. The only // reliable way to terminate a swing application is to call // System.exit(..) which terminates all threads at once. So while we // must terminate the whole server by calling System.exit(), we can // wait here forever until the communication channel breaks. If this // happens the low-level php protocol code automatically calls // exit(6). (If use use a php version with debug symbols, it will // abort and dump core instead, but that's what we expect). -- To // repeate the above statement: PLEASE DO NOT USE SWING TO CREATE A // GUI, please use SWT, GTK or any other toolkit instead! $Thread = new JavaClass("java.lang.Thread"); // don't forget to make the current thread a daemon thread, otherwise // the VM will not exit because it waits for the thread to terminate, // see discussion above. while (true) { $Thread->sleep(99999); }