diff options
Diffstat (limited to 'libjava/classpath/javax/swing/plaf/basic/BasicOptionPaneUI.java')
-rw-r--r-- | libjava/classpath/javax/swing/plaf/basic/BasicOptionPaneUI.java | 36 |
1 files changed, 27 insertions, 9 deletions
diff --git a/libjava/classpath/javax/swing/plaf/basic/BasicOptionPaneUI.java b/libjava/classpath/javax/swing/plaf/basic/BasicOptionPaneUI.java index 6b37d315fa8..005a3b394a8 100644 --- a/libjava/classpath/javax/swing/plaf/basic/BasicOptionPaneUI.java +++ b/libjava/classpath/javax/swing/plaf/basic/BasicOptionPaneUI.java @@ -774,7 +774,7 @@ public class BasicOptionPaneUI extends OptionPaneUI // it will create a box and burst the string. // otherwise, it will just create a label and re-call // this method with the label o.O - if (msg.toString().length() > maxll) + if (msg.toString().length() > maxll || msg.toString().contains("\n")) { Box tmp = new Box(BoxLayout.Y_AXIS); burstStringInto(tmp, msg.toString(), maxll); @@ -796,17 +796,35 @@ public class BasicOptionPaneUI extends OptionPaneUI */ protected void burstStringInto(Container c, String d, int maxll) { - // FIXME: Verify that this is the correct behaviour. - // One interpretation of the spec is that this method - // should recursively call itself to create (and add) - // JLabels to the container if the length of the String d - // is greater than maxll. - // but in practice, even with a really long string, this is - // all that happens. if (d == null || c == null) return; - JLabel label = new JLabel(d); + + int newlineIndex = d.indexOf('\n'); + String line; + String remainder; + if (newlineIndex >= 0 && newlineIndex < maxll) + { + line = d.substring(0, newlineIndex); + remainder = d.substring(newlineIndex + 1); + } + else + { + line = d.substring(0, maxll); + remainder = d.substring(maxll); + } + JLabel label = new JLabel(line); c.add(label); + + // If there is nothing left to burst, then we can stop. + if (remainder.length() == 0) + return; + + // Recursivly call ourselves to burst the remainder of the string, + if ((remainder.length() > maxll || remainder.contains("\n"))) + burstStringInto(c, remainder, maxll); + else + // Add the remainder to the container and be done. + c.add(new JLabel(remainder)); } /** |