类java.awt.desktop.QuitStrategy源码实例Demo

下面列出了怎么用java.awt.desktop.QuitStrategy的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: openjdk-jdk9   文件: _AppEventHandler.java
_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);
    }
}
 
源代码2 项目: openjdk-jdk9   文件: _AppEventHandler.java
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);
    }
}
 
源代码3 项目: opencards   文件: OpenCardsWrapper4MacOSX.java
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();
            }
        });
    }
 
源代码4 项目: openjdk-jdk9   文件: _AppEventHandler.java
void setDefaultQuitStrategy(final QuitStrategy defaultQuitAction) {
    this.defaultQuitAction = defaultQuitAction;
}
 
源代码5 项目: Bytecoder   文件: Desktop.java
/**
 * 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);
}
 
源代码6 项目: openjdk-jdk9   文件: Desktop.java
/**
 * 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);
}
 
源代码7 项目: Bytecoder   文件: DesktopPeer.java
/**
 * 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) {
}
 
源代码8 项目: openjdk-jdk9   文件: DesktopPeer.java
/**
 * 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) {
}
 
源代码9 项目: openjdk-jdk9   文件: Application.java
/**
 * 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);
}
 
 类所在包
 类方法
 同包方法