src/java.desktop/share/classes/javax/swing/JComponent.java

Print this page

        

@@ -55,10 +55,11 @@
 import javax.swing.event.*;
 import javax.swing.plaf.*;
 import static javax.swing.ClientPropertyKey.*;
 import javax.accessibility.*;
 
+import sun.awt.AWTAccessor;
 import sun.awt.SunToolkit;
 import sun.swing.SwingUtilities2;
 import sun.swing.UIClientPropertyKey;
 
 /**

@@ -4216,13 +4217,14 @@
      * have a native window system peer.
      *
      * @param c  the {@code Component} to be checked
      * @return true if this component is lightweight
      */
-    @SuppressWarnings("deprecation")
     public static boolean isLightweightComponent(Component c) {
-        return c.getPeer() instanceof LightweightPeer;
+        // TODO we cannot call c.isLightweight() because it is incorrectly
+        // overriden in DelegateContainer on osx.
+        return AWTAccessor.getComponentAccessor().isLightweight(c);
     }
 
 
     /**
      * @deprecated As of JDK 5,

@@ -5031,11 +5033,10 @@
 
     void setPaintingChild(Component paintingChild) {
         this.paintingChild = paintingChild;
     }
 
-    @SuppressWarnings("deprecation")
     void _paintImmediately(int x, int y, int w, int h) {
         Graphics g;
         Container c;
         Rectangle b;
 

@@ -5157,11 +5158,11 @@
                     offsetY += by;
                 }
         }
 
         // If the clip width or height is negative, don't bother painting
-        if(c == null || c.getPeer() == null ||
+        if(c == null || !c.isDisplayable() ||
                         paintImmediatelyClip.width <= 0 ||
                         paintImmediatelyClip.height <= 0) {
             recycleRectangle(paintImmediatelyClip);
             return;
         }