src/java.desktop/macosx/classes/com/apple/eawt/Application.java

Print this page


   1 /*
   2  * Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.apple.eawt;
  27 
  28 import java.awt.*;
  29 import java.awt.peer.*;



  30 import java.beans.Beans;
  31 
  32 import javax.swing.JMenuBar;
  33 
  34 import sun.lwawt.*;
  35 import sun.lwawt.macosx.*;

  36 
  37 /**
  38  * The <code>Application</code> class allows you to integrate your Java application with the native Mac OS X environment.
  39  * You can provide your Mac OS X users a greatly enhanced experience by implementing a few basic handlers for standard system events.
  40  *
  41  * For example:
  42  * <ul>
  43  * <li>Open an about dialog when a user chooses About from the application menu.</li>
  44  * <li>Open a preferences window when the users chooses Preferences from the application menu.</li>
  45  * <li>Create a new document when the user clicks on your Dock icon, and no windows are open.</li>
  46  * <li>Open a document that the user double-clicked on in the Finder.</li>
  47  * <li>Open a custom URL scheme when a user clicks on link in a web browser.</li>
  48  * <li>Reconnect to network services after the system has awoke from sleep.</li>
  49  * <li>Cleanly shutdown your application when the user chooses Quit from the application menu, Dock icon, or types Command-Q.</li>
  50  * <li>Cancel shutdown/logout if the user has unsaved changes in your application.</li>
  51  * </ul>
  52  *
  53  * @since 1.4
  54  */
  55 public class Application {


 368      * Only used when the system property "apple.laf.useScreenMenuBar" is "true", and
 369      * the Aqua Look and Feel is active.
 370      *
 371      * @param menuBar to use when no other frames are active
 372      *
 373      * @since Java for Mac OS X 10.6 Update 1
 374      * @since Java for Mac OS X 10.5 Update 6 - 1.6, 1.5
 375      */
 376     public void setDefaultMenuBar(final JMenuBar menuBar) {
 377         menuBarHandler.setDefaultMenuBar(menuBar);
 378     }
 379 
 380     /**
 381      * Requests that a {@link Window} should animate into or out of full screen mode.
 382      * Only {@link Window}s marked as full screenable by {@link FullScreenUtilities#setWindowCanFullScreen(Window, boolean)} can be toggled.
 383      *
 384      * @param window to animate into or out of full screen mode
 385      *
 386      * @since Java for Mac OS X 10.7 Update 1
 387      */
 388     @SuppressWarnings("deprecation")
 389     public void requestToggleFullScreen(final Window window) {
 390         final ComponentPeer peer = window.getPeer();
 391 
 392         if (!(peer instanceof LWWindowPeer)) return;
 393         Object platformWindow = ((LWWindowPeer) peer).getPlatformWindow();
 394         if (!(platformWindow instanceof CPlatformWindow)) return;
 395         ((CPlatformWindow)platformWindow).toggleFullScreen();
 396     }
 397 
 398 
 399     // -- DEPRECATED API --
 400 
 401     /**
 402      * Adds the specified ApplicationListener as a receiver of callbacks from this class.
 403      * This method throws a RuntimeException if the newer About, Preferences, Quit, etc handlers are installed.
 404      *
 405      * @param listener an implementation of ApplicationListener that handles ApplicationEvents
 406      *
 407      * @deprecated register individual handlers for each task (About, Preferences, Open, Print, Quit, etc)
 408      * @since 1.4
 409      */
 410     @SuppressWarnings("deprecation")
 411     @Deprecated


   1 /*
   2  * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.apple.eawt;
  27 
  28 import java.awt.Image;
  29 import java.awt.Point;
  30 import java.awt.PopupMenu;
  31 import java.awt.Toolkit;
  32 import java.awt.Window;
  33 import java.beans.Beans;
  34 
  35 import javax.swing.JMenuBar;
  36 
  37 import sun.awt.AWTAccessor;
  38 import sun.lwawt.LWWindowPeer;
  39 import sun.lwawt.macosx.CPlatformWindow;
  40 
  41 /**
  42  * The <code>Application</code> class allows you to integrate your Java application with the native Mac OS X environment.
  43  * You can provide your Mac OS X users a greatly enhanced experience by implementing a few basic handlers for standard system events.
  44  *
  45  * For example:
  46  * <ul>
  47  * <li>Open an about dialog when a user chooses About from the application menu.</li>
  48  * <li>Open a preferences window when the users chooses Preferences from the application menu.</li>
  49  * <li>Create a new document when the user clicks on your Dock icon, and no windows are open.</li>
  50  * <li>Open a document that the user double-clicked on in the Finder.</li>
  51  * <li>Open a custom URL scheme when a user clicks on link in a web browser.</li>
  52  * <li>Reconnect to network services after the system has awoke from sleep.</li>
  53  * <li>Cleanly shutdown your application when the user chooses Quit from the application menu, Dock icon, or types Command-Q.</li>
  54  * <li>Cancel shutdown/logout if the user has unsaved changes in your application.</li>
  55  * </ul>
  56  *
  57  * @since 1.4
  58  */
  59 public class Application {


 372      * Only used when the system property "apple.laf.useScreenMenuBar" is "true", and
 373      * the Aqua Look and Feel is active.
 374      *
 375      * @param menuBar to use when no other frames are active
 376      *
 377      * @since Java for Mac OS X 10.6 Update 1
 378      * @since Java for Mac OS X 10.5 Update 6 - 1.6, 1.5
 379      */
 380     public void setDefaultMenuBar(final JMenuBar menuBar) {
 381         menuBarHandler.setDefaultMenuBar(menuBar);
 382     }
 383 
 384     /**
 385      * Requests that a {@link Window} should animate into or out of full screen mode.
 386      * Only {@link Window}s marked as full screenable by {@link FullScreenUtilities#setWindowCanFullScreen(Window, boolean)} can be toggled.
 387      *
 388      * @param window to animate into or out of full screen mode
 389      *
 390      * @since Java for Mac OS X 10.7 Update 1
 391      */

 392     public void requestToggleFullScreen(final Window window) {
 393         final Object peer = AWTAccessor.getComponentAccessor().getPeer(window);

 394         if (!(peer instanceof LWWindowPeer)) return;
 395         Object platformWindow = ((LWWindowPeer) peer).getPlatformWindow();
 396         if (!(platformWindow instanceof CPlatformWindow)) return;
 397         ((CPlatformWindow)platformWindow).toggleFullScreen();
 398     }
 399 
 400 
 401     // -- DEPRECATED API --
 402 
 403     /**
 404      * Adds the specified ApplicationListener as a receiver of callbacks from this class.
 405      * This method throws a RuntimeException if the newer About, Preferences, Quit, etc handlers are installed.
 406      *
 407      * @param listener an implementation of ApplicationListener that handles ApplicationEvents
 408      *
 409      * @deprecated register individual handlers for each task (About, Preferences, Open, Print, Quit, etc)
 410      * @since 1.4
 411      */
 412     @SuppressWarnings("deprecation")
 413     @Deprecated