< 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,17 +217,23 @@
         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);
         }
+        }
 
         return taskbar;
     }
 
     /**
< prev index next >