On Thu, 27 Oct 2005 13:56:32 +0200 Brendon McLean
<email@hidden> wrote:
Strictly speaking, your HTML isn't actually giving any clues to how
wide the label should be and even if it did, Swing would most likely
ignore it (I'm guessing here).
. . .
Then do something queasy like this:
String[] lines = message.split("\n"); // yeah, yeah File.newline or
whatever
for (String line : lines) {
listModel.addElement(line);
}
I've had to use something similar to wrap paragraphs of text for
display:
public static String wrap(final String s, final int wrapLength, final
char lineSeparator)
{
StringBuffer sb = new StringBuffer(s);
int i = wrapLength;
while (i<sb.length() && i>0)
{
if (Character.isWhitespace(sb.charAt(i)))
{
// If character is whitespace, replace it with a
// lineSeparator and increment index i by wrapLength.
sb.setCharAt(i, lineSeparator);
i += wrapLength;
}
else
{
// Decrement index i by 1 to find the nearest space
// to the left in the sentence at which to wrap.
i--;
}
}
return sb.toString();
}
- Craig
---------------------------------------------------------
"Did you ever wake up to find,
a day that broke up your mind?
Destroyed the notion of circular time?
It's just that evil life that's got you in its sway."
- "Sway", Brown Sugar, Rolling Stones
---------------------------------------------------------
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden