jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTextUI.java
changeset 40160 b819110f8a53
parent 32131 f6daa59ae211
child 41807 f9eb6cb54fed
--- a/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTextUI.java	Fri Jul 29 10:50:49 2016 +0300
+++ b/jdk/src/java.desktop/share/classes/javax/swing/plaf/basic/BasicTextUI.java	Fri Jul 29 10:56:30 2016 +0300
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2016, 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
@@ -940,9 +940,10 @@
                 rootView.setSize(d.width - i.left - i.right -
                         caretMargin, d.height - i.top - i.bottom);
             }
-            else if (d.width <= 0 || d.height <= 0) {
+            else if (!rootViewInitialized && (d.width <= 0 || d.height <= 0)) {
                 // Probably haven't been layed out yet, force some sort of
                 // initial sizing.
+                rootViewInitialized = true;
                 rootView.setSize(Integer.MAX_VALUE, Integer.MAX_VALUE);
             }
             d.width = (int) Math.min((long) rootView.getPreferredSpan(View.X_AXIS) +
@@ -1346,6 +1347,7 @@
     private static final Position.Bias[] discardBias = new Position.Bias[1];
     private DefaultCaret dropCaret;
     private int caretMargin;
+    private boolean rootViewInitialized;
 
     /**
      * Root view that acts as a gateway between the component