173 private void checkFeatureSupport(Feature featureType){ 174 if (!isSupported(featureType)) { 175 throw new UnsupportedOperationException("The " + featureType.name() 176 + " feature is not supported on the current platform!"); 177 } 178 } 179 180 /** 181 * Calls to the security manager's {@code checkPermission} method with 182 * an {@code AWTPermission("showWindowWithoutWarningBanner")} 183 * permission. 184 */ 185 private void checkAWTPermission(){ 186 SecurityManager sm = System.getSecurityManager(); 187 if (sm != null) { 188 sm.checkPermission(new AWTPermission( 189 "showWindowWithoutWarningBanner")); 190 } 191 } 192 193 private Taskbar() { 194 Toolkit defaultToolkit = Toolkit.getDefaultToolkit(); 195 if (defaultToolkit instanceof SunToolkit) { 196 peer = ((SunToolkit) defaultToolkit).createTaskbarPeer(this); 197 } 198 } 199 200 /** 201 * Returns the {@code Taskbar} instance of the current 202 * taskbar context. On some platforms the Taskbar API may not be 203 * supported; use the {@link #isTaskbarSupported} method to 204 * determine if the current taskbar is supported. 205 * @return the Taskbar instance 206 * @throws HeadlessException if {@link 207 * GraphicsEnvironment#isHeadless()} returns {@code true} 208 * @throws UnsupportedOperationException if this class is not 209 * supported on the current platform 210 * @see #isTaskbarSupported() 211 * @see java.awt.GraphicsEnvironment#isHeadless 212 */ 213 public static synchronized Taskbar getTaskbar(){ 214 if (GraphicsEnvironment.isHeadless()) throw new HeadlessException(); 215 216 if (!Taskbar.isTaskbarSupported()) { 217 throw new UnsupportedOperationException("Taskbar API is not " + 218 "supported on the current platform"); 219 } 220 221 sun.awt.AppContext context = sun.awt.AppContext.getAppContext(); 222 Taskbar taskbar = (Taskbar)context.get(Taskbar.class); 223 224 if (taskbar == null) { 225 taskbar = new Taskbar(); 226 context.put(Taskbar.class, taskbar); 227 } 228 229 return taskbar; 230 } 231 232 /** 233 * Tests whether this class is supported on the current platform. 234 * If it's supported, use {@link #getTaskbar()} to retrieve an | 173 private void checkFeatureSupport(Feature featureType){ 174 if (!isSupported(featureType)) { 175 throw new UnsupportedOperationException("The " + featureType.name() 176 + " feature is not supported on the current platform!"); 177 } 178 } 179 180 /** 181 * Calls to the security manager's {@code checkPermission} method with 182 * an {@code AWTPermission("showWindowWithoutWarningBanner")} 183 * permission. 184 */ 185 private void checkAWTPermission(){ 186 SecurityManager sm = System.getSecurityManager(); 187 if (sm != null) { 188 sm.checkPermission(new AWTPermission( 189 "showWindowWithoutWarningBanner")); 190 } 191 } 192 193 private static void checkEventsProcessingPermission() { 194 SecurityManager sm = System.getSecurityManager(); 195 if (sm != null) { 196 sm.checkPermission(new RuntimePermission( 197 "canProcessApplicationEvents")); 198 } 199 } 200 201 private Taskbar() { 202 Toolkit defaultToolkit = Toolkit.getDefaultToolkit(); 203 if (defaultToolkit instanceof SunToolkit) { 204 peer = ((SunToolkit) defaultToolkit).createTaskbarPeer(this); 205 } 206 } 207 208 /** 209 * Returns the {@code Taskbar} instance of the current 210 * taskbar context. On some platforms the Taskbar API may not be 211 * supported; use the {@link #isTaskbarSupported} method to 212 * determine if the current taskbar is supported. 213 * @return the Taskbar instance 214 * @throws HeadlessException if {@link 215 * GraphicsEnvironment#isHeadless()} returns {@code true} 216 * @throws SecurityException if a security manager exists and it 217 * denies the {@code RuntimePermission("canProcessApplicationEvents")} 218 * permission 219 * @throws UnsupportedOperationException if this class is not 220 * supported on the current platform 221 * @see #isTaskbarSupported() 222 * @see java.awt.GraphicsEnvironment#isHeadless 223 */ 224 public static synchronized Taskbar getTaskbar(){ 225 if (GraphicsEnvironment.isHeadless()) throw new HeadlessException(); 226 checkEventsProcessingPermission(); 227 228 if (!Taskbar.isTaskbarSupported()) { 229 throw new UnsupportedOperationException("Taskbar API is not " + 230 "supported on the current platform"); 231 } 232 233 sun.awt.AppContext context = sun.awt.AppContext.getAppContext(); 234 Taskbar taskbar = (Taskbar)context.get(Taskbar.class); 235 236 if (taskbar == null) { 237 taskbar = new Taskbar(); 238 context.put(Taskbar.class, taskbar); 239 } 240 241 return taskbar; 242 } 243 244 /** 245 * Tests whether this class is supported on the current platform. 246 * If it's supported, use {@link #getTaskbar()} to retrieve an |