final Font specialFont = normalFont.deriveFont(Font.ITALIC);
try {
// recreate the string without the # characters
final StringBuilder temp = new StringBuilder();
FormatTextParser parser = new FormatTextParserExtension(temp);
parser.format(line);
// create the attribute string including formating
final AttributedString aStyledText = new AttributedString(temp.toString());
parser = new FormatTextParser() {
private int s = 0;
@Override
public void normalText(final String tok) {
if (tok.length() > 0) {
aStyledText.addAttribute(TextAttribute.FONT, normalFont, s, s
+ tok.length());
aStyledText.addAttribute(TextAttribute.FOREGROUND, normalColor, s, s
+ tok.length());
s += tok.length();
}
}
@Override
public void colorText(final String tok) {
if (tok.length() > 0) {
aStyledText.addAttribute(TextAttribute.FONT, specialFont, s, s
+ tok.length());
aStyledText.addAttribute(TextAttribute.FOREGROUND, Color.blue, s, s
+ tok.length());
s += tok.length();
}
}
};
parser.format(line);
return aStyledText;
} catch (final Exception e) {
Logger.getLogger(TextBoxFactory.class).error(e, e);
return null;