jdk/src/share/classes/javax/swing/JEditorPane.java
changeset 3737 83fb4621a129
parent 1301 15e81207e1f2
child 3750 4195b035138f
--- a/jdk/src/share/classes/javax/swing/JEditorPane.java	Mon Aug 24 18:21:47 2009 +0400
+++ b/jdk/src/share/classes/javax/swing/JEditorPane.java	Mon Aug 24 19:22:38 2009 +0400
@@ -24,6 +24,8 @@
  */
 package javax.swing;
 
+import sun.swing.SwingUtilities2;
+
 import java.awt.*;
 import java.awt.event.*;
 import java.lang.reflect.*;
@@ -1323,8 +1325,8 @@
      */
     public Dimension getPreferredSize() {
         Dimension d = super.getPreferredSize();
-        if (getParent() instanceof JViewport) {
-            JViewport port = (JViewport)getParent();
+        JViewport port = SwingUtilities2.getViewport(this);
+        if (port != null) {
             TextUI ui = getUI();
             int prefWidth = d.width;
             int prefHeight = d.height;
@@ -1445,8 +1447,8 @@
      * match its own, false otherwise
      */
     public boolean getScrollableTracksViewportWidth() {
-        if (getParent() instanceof JViewport) {
-            JViewport port = (JViewport)getParent();
+        JViewport port = SwingUtilities2.getViewport(this);
+        if (port != null) {
             TextUI ui = getUI();
             int w = port.getWidth();
             Dimension min = ui.getMinimumSize(this);
@@ -1467,8 +1469,8 @@
      *          false otherwise
      */
     public boolean getScrollableTracksViewportHeight() {
-        if (getParent() instanceof JViewport) {
-            JViewport port = (JViewport)getParent();
+        JViewport port = SwingUtilities2.getViewport(this);
+        if (port != null) {
             TextUI ui = getUI();
             int h = port.getHeight();
             Dimension min = ui.getMinimumSize(this);