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 {
56 private static native void nativeInitializeApplicationDelegate();
57
58 static Application sApplication = null;
59
60 static {
61 java.security.AccessController.doPrivileged(
62 new java.security.PrivilegedAction<Void>() {
63 public Void run() {
64 System.loadLibrary("awt");
65 return null;
66 }
67 });
68
69 checkSecurity();
70 if (!Beans.isDesignTime()) {
71 nativeInitializeApplicationDelegate();
72 }
73
74 sApplication = new Application();
75 }
76
77 private static void checkSecurity() {
78 final SecurityManager security = System.getSecurityManager();
79 if (security == null) return;
80 security.checkPermission(new RuntimePermission("canProcessApplicationEvents"));
81 }
82
83 /**
84 * @return the singleton representing this Mac OS X Application
85 *
86 * @since 1.4
87 */
88 public static Application getApplication() {
89 checkSecurity();
|
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 {
56 private static native void nativeInitializeApplicationDelegate();
57
58 static Application sApplication = null;
59
60 static {
61 checkSecurity();
62 Toolkit.getDefaultToolkit(); // Start AppKit
63 if (!Beans.isDesignTime()) {
64 nativeInitializeApplicationDelegate();
65 }
66
67 sApplication = new Application();
68 }
69
70 private static void checkSecurity() {
71 final SecurityManager security = System.getSecurityManager();
72 if (security == null) return;
73 security.checkPermission(new RuntimePermission("canProcessApplicationEvents"));
74 }
75
76 /**
77 * @return the singleton representing this Mac OS X Application
78 *
79 * @since 1.4
80 */
81 public static Application getApplication() {
82 checkSecurity();
|