Я пытаюсь сделать BOLD текст в JPane, но он не работает. Если это ИТАЛИЯ или UNDERLINE его рабочий тон. Ниже мой код.JtextPane - невозможно использовать BOLD
String strText = "<b><i><u>Testing</b></i></u>";
javax.swing.text.Style style1 = jTextPane1.addStyle("I'm a Style", null);
StyleConstants.setForeground(style1, Color.BLACK);
StyleConstants.setFontSize(style1, 15);
StyleConstants.setFontFamily(style1, "Arial Unicode MS");
if(strText.contains("<b>"))
{
StyleConstants.setBold(style1, true);
strText = strText.replace("<b>", " ");
strText = strText.replace("</b>", " ");
}
if(strText.contains("<i>"))
{
StyleConstants.setItalic(style1, true);
strText = strText.replace("<i>", " ");
strText = strText.replace("</i>", " ");
}
if(strText.contains("<u>"))
{
StyleConstants.setUnderline(style1, true);
strText = strText.replace("<u>", " ");
strText = strText.replace("</u>", " ");
}
try {
strText = strText.trim();
doc.insertString(doc.getLength(), strText, style1);
}
UNDERLINE и ITALIC работает отлично тем BOLD не работает в соответствии ожидается. Текст не BOLDED. Пожалуйста, совет, где я сделал ошибки.
'StyleConstants.setBold (style1, ложь);' ... Do вы действительно хотите установить его в false? – Vulcan
привет, я думаю, что проблема не в этой части кода, это просто хорошо – BilalDja
Вот полный пример [здесь] (http://stackoverflow.com/a/15600689/230513). – trashgod