src/macosx/classes/com/apple/eawt/_AppEventHandler.java

Print this page




 140         currentQuitResponse = null;
 141 
 142         try {
 143             if (defaultQuitAction == QuitStrategy.SYSTEM_EXIT_0) System.exit(0);
 144 
 145             if (defaultQuitAction != QuitStrategy.CLOSE_ALL_WINDOWS) {
 146                 throw new RuntimeException("Unknown quit action");
 147             }
 148 
 149             EventQueue.invokeLater(new Runnable() {
 150                 public void run() {
 151                     // walk frames from back to front
 152                     final Frame[] allFrames = Frame.getFrames();
 153                     for (int i = allFrames.length - 1; i >= 0; i--) {
 154                         final Frame frame = allFrames[i];
 155                         frame.dispatchEvent(new WindowEvent(frame, WindowEvent.WINDOW_CLOSING));
 156                     }
 157                 }
 158             });
 159         } finally {
 160             nativeReplyToAppShouldTerminate(true);



 161         }
 162     }
 163 
 164     /*
 165      * callbacks from native delegate
 166      */
 167     private static void handlePrintFiles(final List<String> filenames) {
 168         instance.printFilesDispatcher.dispatch(new _NativeEvent(filenames));
 169     }
 170 
 171     private static void handleOpenFiles(final List<String> filenames, final String searchTerm) {
 172         instance.openFilesDispatcher.dispatch(new _NativeEvent(filenames, searchTerm));
 173     }
 174 
 175     private static void handleOpenURI(final String uri) {
 176         instance.openURIDispatcher.dispatch(new _NativeEvent(uri));
 177     }
 178 
 179     // default funnel for non-complex events
 180     private static void handleNativeNotification(final int code) {




 140         currentQuitResponse = null;
 141 
 142         try {
 143             if (defaultQuitAction == QuitStrategy.SYSTEM_EXIT_0) System.exit(0);
 144 
 145             if (defaultQuitAction != QuitStrategy.CLOSE_ALL_WINDOWS) {
 146                 throw new RuntimeException("Unknown quit action");
 147             }
 148 
 149             EventQueue.invokeLater(new Runnable() {
 150                 public void run() {
 151                     // walk frames from back to front
 152                     final Frame[] allFrames = Frame.getFrames();
 153                     for (int i = allFrames.length - 1; i >= 0; i--) {
 154                         final Frame frame = allFrames[i];
 155                         frame.dispatchEvent(new WindowEvent(frame, WindowEvent.WINDOW_CLOSING));
 156                     }
 157                 }
 158             });
 159         } finally {
 160             // Either we've just called System.exit(), or the app will call
 161             // it when processing a WINDOW_CLOSING event. Either way, we reply
 162             // to Cocoa that we don't want to exit the event loop yet.
 163             nativeReplyToAppShouldTerminate(false);
 164         }
 165     }
 166 
 167     /*
 168      * callbacks from native delegate
 169      */
 170     private static void handlePrintFiles(final List<String> filenames) {
 171         instance.printFilesDispatcher.dispatch(new _NativeEvent(filenames));
 172     }
 173 
 174     private static void handleOpenFiles(final List<String> filenames, final String searchTerm) {
 175         instance.openFilesDispatcher.dispatch(new _NativeEvent(filenames, searchTerm));
 176     }
 177 
 178     private static void handleOpenURI(final String uri) {
 179         instance.openURIDispatcher.dispatch(new _NativeEvent(uri));
 180     }
 181 
 182     // default funnel for non-complex events
 183     private static void handleNativeNotification(final int code) {