jdk/src/share/classes/javax/swing/JList.java
changeset 3737 83fb4621a129
parent 1301 15e81207e1f2
child 4278 b7a976422d27
--- a/jdk/src/share/classes/javax/swing/JList.java	Mon Aug 24 18:21:47 2009 +0400
+++ b/jdk/src/share/classes/javax/swing/JList.java	Mon Aug 24 19:22:38 2009 +0400
@@ -2722,8 +2722,9 @@
                                       getVisibleRowCount() <= 0) {
             return true;
         }
-        if (getParent() instanceof JViewport) {
-            return (getParent().getWidth() > getPreferredSize().width);
+        JViewport port = SwingUtilities2.getViewport(this);
+        if (port != null) {
+            return port.getWidth() > getPreferredSize().width;
         }
         return false;
     }
@@ -2747,8 +2748,9 @@
                      getVisibleRowCount() <= 0) {
             return true;
         }
-        if (getParent() instanceof JViewport) {
-            return (getParent().getHeight() > getPreferredSize().height);
+        JViewport port = SwingUtilities2.getViewport(this);
+        if (port != null) {
+            return port.getHeight() > getPreferredSize().height;
         }
         return false;
     }