src/share/classes/javax/swing/plaf/nimbus/NimbusIcon.java

Print this page

        

@@ -1,7 +1,7 @@
 /*
- * Copyright (c) 2005, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
  * under the terms of the GNU General Public License version 2 only, as
  * published by the Free Software Foundation.  Oracle designates this

@@ -48,19 +48,24 @@
         this.height = h;
         this.prefix = prefix;
         this.key = key;
     }
 
+    @SuppressWarnings("unchecked")
+    private static Painter<JComponent> paintFilter(@SuppressWarnings("rawtypes") Painter painter) {
+        return (Painter<JComponent>) painter;
+    }
+
     @Override
     public void paintIcon(SynthContext context, Graphics g, int x, int y,
                           int w, int h) {
-        Painter painter = null;
+        Painter<JComponent> painter = null;
         if (context != null) {
-            painter = (Painter)context.getStyle().get(context, key);
+            painter = paintFilter((Painter)context.getStyle().get(context, key));
         }
         if (painter == null){
-            painter = (Painter) UIManager.get(prefix + "[Enabled]." + key);
+            painter = paintFilter((Painter)UIManager.get(prefix + "[Enabled]." + key));
         }
 
         if (painter != null && context != null) {
             JComponent c = context.getComponent();
             boolean rotate = false;

@@ -138,11 +143,12 @@
      * paint any thing, so we override here so that we can paint the enabled
      * state if no synth context is available
      */
     @Override
     public void paintIcon(Component c, Graphics g, int x, int y) {
-        Painter painter = (Painter)UIManager.get(prefix + "[Enabled]." + key);
+        Painter<JComponent> painter =
+            paintFilter((Painter)UIManager.get(prefix + "[Enabled]." + key));
         if (painter != null){
             JComponent jc = (c instanceof JComponent) ? (JComponent)c : null;
             Graphics2D gfx = (Graphics2D)g;
             gfx.translate(x, y);
             painter.paint(gfx, jc , width, height);