< prev index next >

src/java.desktop/share/classes/java/awt/Desktop.java

Print this page

        

*** 277,286 **** --- 277,288 ---- sm.checkPermission(new RuntimePermission( "canProcessApplicationEvents")); } } + private static Desktop desktop; + /** * Returns the {@code Desktop} instance of the current * desktop context. On some platforms the Desktop API may not be * supported; use the {@link #isDesktopSupported} method to * determine if the current desktop is supported.
*** 298,312 **** throw new UnsupportedOperationException("Desktop API is not " + "supported on the current platform"); } sun.awt.AppContext context = sun.awt.AppContext.getAppContext(); ! Desktop desktop = (Desktop)context.get(Desktop.class); if (desktop == null) { desktop = new Desktop(); context.put(Desktop.class, desktop); } return desktop; } --- 300,321 ---- throw new UnsupportedOperationException("Desktop API is not " + "supported on the current platform"); } sun.awt.AppContext context = sun.awt.AppContext.getAppContext(); ! ! Desktop desktop = (context == null) ! ? Desktop.desktop ! : (Desktop)context.get(Desktop.class); if (desktop == null) { desktop = new Desktop(); + if (context != null) { context.put(Desktop.class, desktop); + } else { + Desktop.desktop = desktop; + } } return desktop; }
< prev index next >