Java JTextArea用粗体字体突出文本
我需要在字符串中突出显示几个单词,同时将其附加到JTextArea。所以我试着这样做:Java JTextArea用粗体字体突出文本,java,swing,jtextarea,Java,Swing,Jtextarea,我需要在字符串中突出显示几个单词,同时将其附加到JTextArea。所以我试着这样做: jta.append("<html> <b>Termination time : </b></html>" + CriterionFunction.estimateIndividual_top(individual) + "\n"); jta.append(“终止时间:”+ CriterionFunction.
jta.append("<html> <b>Termination time : </b></html>" +
CriterionFunction.estimateIndividual_top(individual) + "\n");
jta.append(“终止时间:”+
CriterionFunction.estimateIndividual_top(individual)+“\n”);
其中jta是一个JTextArea。我得到的输出是:终止时间:15
我在论坛上读过一些关于这个问题的文章,据说
会有帮助。但事实并非如此
请告诉我。我的错误在哪里?你应该使用
JEditorPane
而不是JTextArea
以下各项应起作用:
JEditorPane jep = new JEditorPane();
jep.setContentType("text/html");
jep.setText("<html> <b>Termination time : </b></html>" + CriterionFunction.estimateIndividual_top(individual) + "\n");
JEditorPane jep=new JEditorPane();
setContentType(“text/html”);
jep.setText(“终止时间:“+CriterionFunction.estimateIndividual\u top(individual)+”\n”);
谢谢!这件工作做得很好。你能告诉我内容可能是什么吗?