Java Code Examples for java.awt.Desktop#setQuitHandler()
The following examples show how to use
java.awt.Desktop#setQuitHandler() .
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: NbApplicationAdapterJDK9.java From netbeans with Apache License 2.0 | 5 votes |
static void install() { try { Desktop app = Desktop.getDesktop(); NbApplicationAdapterJDK9 al = new NbApplicationAdapterJDK9(); app.setAboutHandler(al); app.setOpenFileHandler(al); app.setPreferencesHandler(al); app.setQuitHandler(al); } catch (Throwable ex) { ErrorManager.getDefault().notify(ErrorManager.WARNING, ex); } finally { } NbApplicationAdapter.install(); }
Example 2
Source File: NbApplicationAdapterJDK9.java From netbeans with Apache License 2.0 | 5 votes |
static void uninstall() { Desktop app = Desktop.getDesktop(); app.setAboutHandler(null); app.setOpenFileHandler(null); app.setPreferencesHandler(null); app.setQuitHandler(null); }
Example 3
Source File: DesktopHandler.java From pcgen with GNU Lesser General Public License v2.1 | 5 votes |
/** * Initialize the Mac-specific properties. * Create an ApplicationAdapter to listen for Help, Prefs, and Quit. */ public static void initialize() { if (initialized) { return; } initialized = true; if (!Desktop.isDesktopSupported()) { return; } Desktop theDesktop = Desktop.getDesktop(); if (theDesktop.isSupported(Action.APP_ABOUT)) { theDesktop.setAboutHandler(new AboutHandler()); } if (theDesktop.isSupported(Action.APP_PREFERENCES)) { theDesktop.setPreferencesHandler(new PreferencesHandler()); } if (theDesktop.isSupported(Action.APP_QUIT_HANDLER)) { theDesktop.setQuitHandler(new QuitHandler()); } }
Example 4
Source File: DesktopHandler.java From pcgen with GNU Lesser General Public License v2.1 | 5 votes |
/** * Initialize the Mac-specific properties. * Create an ApplicationAdapter to listen for Help, Prefs, and Quit. */ public static void initialize() { if (initialized) { return; } initialized = true; if (!Desktop.isDesktopSupported()) { return; } Desktop theDesktop = Desktop.getDesktop(); if (theDesktop.isSupported(Action.APP_ABOUT)) { theDesktop.setAboutHandler(new AboutHandler()); } if (theDesktop.isSupported(Action.APP_PREFERENCES)) { theDesktop.setPreferencesHandler(new PreferencesHandler()); } if (theDesktop.isSupported(Action.APP_QUIT_HANDLER)) { theDesktop.setQuitHandler(new QuitHandler()); } }
Example 5
Source File: DesktopSetup.java From mzmine3 with GNU General Public License v2.0 | 4 votes |
@Override public void run() { logger.finest("Configuring desktop settings"); // Set basic desktop handlers final Desktop awtDesktop = Desktop.getDesktop(); if (awtDesktop != null) { // Setup About handler if (awtDesktop.isSupported(Desktop.Action.APP_ABOUT)) { awtDesktop.setAboutHandler(e -> { MZmineGUI.showAboutWindow(); }); } // Setup Quit handler if (awtDesktop.isSupported(Desktop.Action.APP_QUIT_HANDLER)) { awtDesktop.setQuitHandler((e, response) -> { ExitCode exitCode = MZmineCore.getDesktop().exitMZmine(); if (exitCode == ExitCode.OK) response.performQuit(); else response.cancelQuit(); }); } } if (Taskbar.isTaskbarSupported()) { final Taskbar taskBar = Taskbar.getTaskbar(); // Set the main app icon if ((mzMineIcon != null) && taskBar.isSupported(Taskbar.Feature.ICON_IMAGE)) { final java.awt.Image mzMineIconAWT = SwingFXUtils.fromFXImage(mzMineIcon, null); taskBar.setIconImage(mzMineIconAWT); } // Add a task controller listener to show task progress MZmineCore.getTaskController().addTaskControlListener((numOfWaitingTasks, percentDone) -> { if (numOfWaitingTasks > 0) { if (taskBar.isSupported(Taskbar.Feature.ICON_BADGE_NUMBER)) { String badge = String.valueOf(numOfWaitingTasks); taskBar.setIconBadge(badge); } if (taskBar.isSupported(Taskbar.Feature.PROGRESS_VALUE)) taskBar.setProgressValue(percentDone); } else { if (taskBar.isSupported(Taskbar.Feature.ICON_BADGE_NUMBER)) taskBar.setIconBadge(null); /* * if (taskBar.isSupported( Taskbar.Feature.PROGRESS_STATE_WINDOW)) * taskBar.setWindowProgressState( MZmineCore.getDesktop().getMainWindow(), * Taskbar.State.OFF); */ if (taskBar.isSupported(Taskbar.Feature.PROGRESS_VALUE)) taskBar.setProgressValue(-1); /* * if (taskBar.isSupported( Taskbar.Feature.PROGRESS_VALUE_WINDOW)) * taskBar.setWindowProgressValue( MZmineCore.getDesktop().getMainWindow(), -1); */ } }); } // Let the OS decide the location of new windows. Otherwise, all windows // would appear at the top left corner by default. // TODO: investigate if this applies to JavaFX windows System.setProperty("java.awt.Window.locationByPlatform", "true"); }