I want to display the values in bold
我需要将值更改为粗体而不是整个文本。
这是我的代码:
public String displayOrder(){
String order = "Order " + count +
"\nLength of pipe: " + decimal2.format(length / 39.37) +
"m" + "\nDiameter of pipe: " + decimal2.format(outerDiameter) +
"''" + "\nGrade of pipe: " + grade +
"\nColour of pipe: " + colour +
"\nInner insulation: " + convertToStr(innerInsulation) +
"\nOuter reinforcement: " + convertToStr(outerReinforcement) +
"\nChemical resistance: " + convertToStr(chemicalResistance) +
"\nNumber of pipes: " + quantityOfPipes;
return order;
}
答案 0 :(得分:0)
我会使用JEditorPane使用html标记:
JEditorPane editorPane = new JEditorPane("text/html", "");
editorPane.setText("Test <b>bold</b>");
你不能用JTextArea做到这一点,你可以更接近改变字体:
textArea.setFont(textArea.getFont().deriveFont(Font.BOLD));
问题是这会改变整个文本的字体。
答案 1 :(得分:0)
我不认为你可以用普通的jtextarea做到这一点,你应该尝试一下 JEditorPane中
int a, b, c;
while(scanf("%d %d %d", &a, &b, &c)==1){
// do stuff here
}