< prev index next >

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

Print this page

        

@@ -194,10 +194,12 @@
         if (defaultToolkit instanceof SunToolkit) {
             peer = ((SunToolkit) defaultToolkit).createTaskbarPeer(this);
         }
     }
 
+    private static Taskbar taskbar;
+
     /**
      * Returns the {@code Taskbar} instance of the current
      * taskbar context.  On some platforms the Taskbar API may not be
      * supported; use the {@link #isTaskbarSupported} method to
      * determine if the current taskbar is supported.

@@ -215,16 +217,24 @@
         if (!Taskbar.isTaskbarSupported()) {
             throw new UnsupportedOperationException("Taskbar API is not " +
                                                     "supported on the current platform");
         }
 
+        Taskbar taskbar = null;
         sun.awt.AppContext context = sun.awt.AppContext.getAppContext();
-        Taskbar taskbar = (Taskbar)context.get(Taskbar.class);
+
+        taskbar = (context == null)
+                ? Taskbar.taskbar
+                : (Taskbar)context.get(Taskbar.class);
 
         if (taskbar == null) {
             taskbar = new Taskbar();
+            if (context != null) {
             context.put(Taskbar.class, taskbar);
+            } else {
+                Taskbar.taskbar = taskbar;
+            }
         }
 
         return taskbar;
     }
 
< prev index next >