< prev index next >

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

Print this page
rev 10947 : 8055723: Replace concat String to append in StringBuilder parameters

@@ -1211,19 +1211,19 @@
     public String toString() {
         if (springsChanged) {
             registerComponents(horizontalGroup, HORIZONTAL);
             registerComponents(verticalGroup, VERTICAL);
         }
-        StringBuffer buffer = new StringBuffer();
-        buffer.append("HORIZONTAL\n");
-        createSpringDescription(buffer, horizontalGroup, "  ", HORIZONTAL);
-        buffer.append("\nVERTICAL\n");
-        createSpringDescription(buffer, verticalGroup, "  ", VERTICAL);
-        return buffer.toString();
+        StringBuilder sb = new StringBuilder();
+        sb.append("HORIZONTAL\n");
+        createSpringDescription(sb, horizontalGroup, "  ", HORIZONTAL);
+        sb.append("\nVERTICAL\n");
+        createSpringDescription(sb, verticalGroup, "  ", VERTICAL);
+        return sb.toString();
     }
 
-    private void createSpringDescription(StringBuffer buffer, Spring spring,
+    private void createSpringDescription(StringBuilder sb, Spring spring,
             String indent, int axis) {
         String origin = "";
         String padding = "";
         if (spring instanceof ComponentSpring) {
             ComponentSpring cSpring = (ComponentSpring)spring;

@@ -1237,24 +1237,23 @@
             AutoPreferredGapSpring paddingSpring =
                     (AutoPreferredGapSpring)spring;
             padding = ", userCreated=" + paddingSpring.getUserCreated() +
                     ", matches=" + paddingSpring.getMatchDescription();
         }
-        buffer.append(indent + spring.getClass().getName() + " " +
-                Integer.toHexString(spring.hashCode()) + " " +
-                origin +
-                ", size=" + spring.getSize() +
-                ", alignment=" + spring.getAlignment() +
-                " prefs=[" + spring.getMinimumSize(axis) +
-                " " + spring.getPreferredSize(axis) +
-                " " + spring.getMaximumSize(axis) +
-                padding + "]\n");
+        sb.append(indent).append(spring.getClass().getName()).append(' ')
+                .append(Integer.toHexString(spring.hashCode())).append(' ')
+                .append(origin).append(", size=").append(spring.getSize())
+                .append(", alignment=").append(spring.getAlignment())
+                .append(" prefs=[").append(spring.getMinimumSize(axis))
+                .append(' ').append(spring.getPreferredSize(axis)).append(' ')
+                .append(spring.getMaximumSize(axis)).append(padding)
+                .append("]\n");
         if (spring instanceof Group) {
             List<Spring> springs = ((Group)spring).springs;
             indent += "  ";
             for (int counter = 0; counter < springs.size(); counter++) {
-                createSpringDescription(buffer, springs.get(counter), indent,
+                createSpringDescription(sb, springs.get(counter), indent,
                         axis);
             }
         }
     }
 
< prev index next >