< prev index next >

src/java.desktop/share/classes/java/awt/peer/DesktopPeer.java

Print this page

        

*** 20,37 **** * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ - package java.awt.peer; - import java.io.File; import java.io.IOException; import java.net.URI; import java.awt.Desktop.Action; /** * The {@code DesktopPeer} interface provides methods for the operation * of open, edit, print, browse and mail with the given URL or file, by * launching the associated application. --- 20,48 ---- * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ package java.awt.peer; import java.io.File; import java.io.IOException; import java.net.URI; import java.awt.Desktop.Action; + import java.awt.Window; + import java.awt.desktop.AboutHandler; + import java.awt.desktop.FileManager; + import java.awt.desktop.FullScreenListener; + import java.awt.desktop.SystemEventListener; + import java.awt.desktop.OpenFilesHandler; + import java.awt.desktop.OpenURIHandler; + import java.awt.desktop.PreferencesHandler; + import java.awt.desktop.PrintFilesHandler; + import java.awt.desktop.QuitHandler; + import java.awt.desktop.QuitStrategy; + import javax.swing.JMenuBar; + import javax.swing.RootPaneContainer; /** * The {@code DesktopPeer} interface provides methods for the operation * of open, edit, print, browse and mail with the given URL or file, by * launching the associated application.
*** 102,107 **** --- 113,342 ---- * @param uri the given URI. * @throws IOException If the user default browser is not found, * or it fails to be launched. */ void browse(URI uri) throws IOException; + + /** + * Adds sub-types of {@link SystemEventListener} to listen for notifications + * from the native system. + * + * @param listener listener + * @see java.awt.desktop.AppForegroundListener + * @see java.awt.desktop.AppHiddenListener + * @see java.awt.desktop.AppReopenedListener + * @see java.awt.desktop.ScreenSleepListener + * @see java.awt.desktop.SystemSleepListener + * @see java.awt.desktop.UserSessionListener + */ + default void addAppEventListener(final SystemEventListener listener) { + } + + /** + * Removes sub-types of {@link SystemEventListener} to listen for notifications + * from the native system. + * + * @param listener listener + * @see java.awt.desktop.AppForegroundListener + * @see java.awt.desktop.AppHiddenListener + * @see java.awt.desktop.AppReopenedListener + * @see java.awt.desktop.ScreenSleepListener + * @see java.awt.desktop.SystemSleepListener + * @see java.awt.desktop.UserSessionListener + */ + default void removeAppEventListener(final SystemEventListener listener) { + } + + /** + * Installs a handler to show a custom About window for your application. + * <p> + * Setting the {@link AboutHandler} to <code>null</code> reverts it to the + * default behavior. + * + * @param aboutHandler the handler to respond to the + * {@link AboutHandler#handleAbout} )} message + */ + default void setAboutHandler(final AboutHandler aboutHandler) { + } + + /** + * Installs a handler to show a custom Preferences window for your + * application. + * <p> + * Setting the {@link PreferencesHandler} to <code>null</code> reverts it to + * the default behavior + * + * @param preferencesHandler the handler to respond to the + * {@link PreferencesHandler#handlePreferences(PreferencesEvent)} + */ + default void setPreferencesHandler(final PreferencesHandler preferencesHandler) { + } + + /** + * Installs the handler which is notified when the application is asked to + * open a list of files. + * + * @param openFileHandler handler + */ + default void setOpenFileHandler(final OpenFilesHandler openFileHandler) { + } + + /** + * Installs the handler which is notified when the application is asked to + * print a list of files. + * + * @param printFileHandler handler + */ + default void setPrintFileHandler(final PrintFilesHandler printFileHandler) { + } + + /** + * Installs the handler which is notified when the application is asked to + * open a URL. + * + * Setting the handler to <code>null</code> causes all + * {@link OpenURIHandler#openURI(AppEvent.OpenURIEvent)} requests to be + * enqueued until another handler is set. + * + * @param openURIHandler handler + */ + default void setOpenURIHandler(final OpenURIHandler openURIHandler) { + } + + /** + * Installs the handler which determines if the application should quit. The + * handler is passed a one-shot {@link QuitResponse} which can cancel or + * proceed with the quit. Setting the handler to <code>null</code> causes + * all quit requests to directly perform the default {@link QuitStrategy}. + * + * @param quitHandler the handler that is called when the application is + * asked to quit + */ + default void setQuitHandler(final QuitHandler quitHandler) { + } + + /** + * 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) { + } + + /** + * Enables this application to be suddenly terminated. + * + * Call this method to indicate your application's state is saved, and + * requires no notification to be terminated. Letting your application + * remain terminatable improves the user experience by avoiding re-paging in + * your application when it's asked to quit. + * + * <b>Note: enabling sudden termination will allow your application to be + * quit without notifying your QuitHandler, or running any shutdown + * hooks.</b> + * E.g. user initiated Cmd-Q, logout, restart, or shutdown requests will + * effectively "kill -KILL" your application. + * + * @see #disableSuddenTermination() + */ + default void enableSuddenTermination() { + } + + /** + * Prevents this application from being suddenly terminated. + * + * Call this method to indicate that your application has unsaved state, and + * may not be terminated without notification. + * + * @see #enableSuddenTermination() + */ + default void disableSuddenTermination() { + } + + /** + * Requests this application to move to the foreground. + * + * @param allWindows if all windows of this application should be moved to + * the foreground, or only the foremost one + */ + default void requestForeground(final boolean allWindows) { + } + + /** + * Opens the native help viewer application. + */ + default void openHelpViewer() { + } + + /** + * Sets the default menu bar to use when there are no active frames. + * + * @param menuBar to use when no other frames are active + */ + default void setDefaultMenuBar(final JMenuBar menuBar) { + } + + /** + * Attaches a {@link FullScreenListener} to the specified top-level + * {@link Window}. + * + * @param window to attach the {@link FullScreenListener} to + * @param listener to be notified when a full screen event occurs + * @throws IllegalArgumentException if window is not a + * {@link RootPaneContainer} + */ + default void addWindowFullScreenListener(final Window window, + final FullScreenListener listener) { + } + + /** + * Removes a {@link FullScreenListener} from the specified top-level + * {@link Window}. + * + * @param window to remove the {@link FullScreenListener} from + * @param listener to be removed + * @throws IllegalArgumentException if window is not a + * {@link RootPaneContainer} + */ + default void removeWindowFullScreenListener(final Window window, + final FullScreenListener listener) { + } + + /** + * Marks a {@link Window} as able to animate into or out of full screen + * mode. + * + * Only top-level {@link Window}s which are {@link RootPaneContainer}s are + * able to be animated into and out of full screen mode. The {@link Window} + * must be marked as full screen-able before the native peer is created with + * {@link Component#addNotify()}. + * + * @param window window + * @param canFullScreen flag + * @throws IllegalArgumentException if window is not a + * {@link RootPaneContainer} + */ + default void setWindowCanFullScreen(final Window window, + final boolean canFullScreen) { + } + + /** + * Requests that a {@link Window} should get into or out of full screen + * mode. Only {@link Window}s marked as full screenable by + * {@link #setWindowCanFullScreen(Window, boolean)} can be toggled. + * + * @param window to animate into or out of full screen mode + */ + default void requestToggleFullScreen(final Window window) { + } + + /** + * Returns the Mac specific FileManager. + * @return FileManager + * @see FileManager + */ + default FileManager getFileManager() { + return null; + } + }
< prev index next >