java.awt.desktop.QuitStrategy Java Examples
The following examples show how to use
java.awt.desktop.QuitStrategy.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: _AppEventHandler.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
_AppEventHandler() { final String strategyProp = System.getProperty("apple.eawt.quitStrategy"); if (strategyProp == null) return; if ("CLOSE_ALL_WINDOWS".equals(strategyProp)) { setDefaultQuitStrategy(QuitStrategy.CLOSE_ALL_WINDOWS); } else if ("SYSTEM_EXIT_O".equals(strategyProp) || "NORMAL_EXIT".equals(strategyProp)) { setDefaultQuitStrategy(QuitStrategy.NORMAL_EXIT); } else { System.err.println("unrecognized apple.eawt.quitStrategy: " + strategyProp); } }
Example #2
Source File: _AppEventHandler.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
synchronized void performQuit() { currentQuitResponse = null; try { if (defaultQuitAction == QuitStrategy.NORMAL_EXIT || _AppMiscHandlers.isSuddenTerminationEnbaled()) System.exit(0); if (defaultQuitAction != QuitStrategy.CLOSE_ALL_WINDOWS) { throw new RuntimeException("Unknown quit action"); } EventQueue.invokeLater(new Runnable() { public void run() { // walk frames from back to front final Frame[] allFrames = Frame.getFrames(); for (int i = allFrames.length - 1; i >= 0; i--) { final Frame frame = allFrames[i]; frame.dispatchEvent(new WindowEvent(frame, WindowEvent.WINDOW_CLOSING)); } } }); } finally { // Either we've just called System.exit(), or the app will call // it when processing a WINDOW_CLOSING event. Either way, we reply // to Cocoa that we don't want to exit the event loop yet. nativeReplyToAppShouldTerminate(false); } }
Example #3
Source File: OpenCardsWrapper4MacOSX.java From opencards with BSD 2-Clause "Simplified" License | 5 votes |
public OpenCardsWrapper4MacOSX() { // set some mac-specific properties System.setProperty("apple.awt.graphics.EnableQ2DX", "true"); System.setProperty("apple.laf.useScreenMenuBar", "true"); System.setProperty("com.apple.mrj.application.apple.menu.about.name", "OpenCards"); oc = new OpenCards(); MacAppHandler macAppHandler = new MacAppHandler(oc); // create an instance of the Mac Application class, so i can handle the // mac quit event with the Mac ApplicationAdapter // Application macApplication = Application.getApplication(); Desktop macApplication = Desktop.getDesktop(); // need to enable the preferences option manually macApplication.setPreferencesHandler(macAppHandler); macApplication.setAboutHandler(macAppHandler); macApplication.setQuitHandler(macAppHandler); macApplication.setQuitStrategy(QuitStrategy.CLOSE_ALL_WINDOWS); macApplication.addAppEventListener(macAppHandler); // display the jframe SwingUtilities.invokeLater(new Runnable() { public void run() { oc.setVisible(true); oc.doAfterSetup(); } }); }
Example #4
Source File: _AppEventHandler.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
void setDefaultQuitStrategy(final QuitStrategy defaultQuitAction) { this.defaultQuitAction = defaultQuitAction; }
Example #5
Source File: Desktop.java From Bytecoder with Apache License 2.0 | 3 votes |
/** * Sets the default strategy used to quit this application. The default is * calling SYSTEM_EXIT_0. * * @param strategy the way this application should be shutdown * * @throws SecurityException if a security manager exists and it * will not allow the caller to invoke {@code System.exit} or it denies the * {@code RuntimePermission("canProcessApplicationEvents")} permission * @throws UnsupportedOperationException if the current platform * does not support the {@link Desktop.Action#APP_QUIT_STRATEGY} action * @see QuitStrategy * @since 9 */ public void setQuitStrategy(final QuitStrategy strategy) { checkEventsProcessingPermission(); checkQuitPermission(); checkActionSupport(Action.APP_QUIT_STRATEGY); peer.setQuitStrategy(strategy); }
Example #6
Source File: Desktop.java From openjdk-jdk9 with GNU General Public License v2.0 | 3 votes |
/** * Sets the default strategy used to quit this application. The default is * calling SYSTEM_EXIT_0. * * @param strategy the way this application should be shutdown * * @throws SecurityException if a security manager exists and it * will not allow the caller to invoke {@code System.exit} or it denies the * {@code RuntimePermission("canProcessApplicationEvents")} permission * @throws UnsupportedOperationException if the current platform * does not support the {@link Desktop.Action#APP_QUIT_STRATEGY} action * @see QuitStrategy * @since 9 */ public void setQuitStrategy(final QuitStrategy strategy) { checkEventsProcessingPermission(); checkQuitPermission(); checkActionSupport(Action.APP_QUIT_STRATEGY); peer.setQuitStrategy(strategy); }
Example #7
Source File: DesktopPeer.java From Bytecoder with Apache License 2.0 | 2 votes |
/** * Sets the default strategy used to quit this application. The default is * calling SYSTEM_EXIT_0. * * @param strategy the way this application should be shutdown */ default void setQuitStrategy(final QuitStrategy strategy) { }
Example #8
Source File: DesktopPeer.java From openjdk-jdk9 with GNU General Public License v2.0 | 2 votes |
/** * Sets the default strategy used to quit this application. The default is * calling SYSTEM_EXIT_0. * * @param strategy the way this application should be shutdown */ default void setQuitStrategy(final QuitStrategy strategy) { }
Example #9
Source File: Application.java From openjdk-jdk9 with GNU General Public License v2.0 | 2 votes |
/** * Sets the default strategy used to quit this application. The default is calling SYSTEM_EXIT_0. * * The quit strategy can also be set with the "apple.eawt.quitStrategy" system property. * * @param strategy the way this application should be shutdown * @since Java for Mac OS X 10.6 Update 3 * @since Java for Mac OS X 10.5 Update 8 */ public void setQuitStrategy(final QuitStrategy strategy) { eventHandler.setDefaultQuitStrategy(strategy); }