你能告诉我如何使部分文本变为粗体:
TextArea dataPane = new TextArea();
dataPane.appendText("Product Version: " + "1.0");
dataPane.appendText("\nJava: " + "7");
dataPane.appendText("\nRuntime: " + "7");
dataPane.appendText("\nSystem: " + "Linux");
dataPane.appendText("\nUser directory: " + "/home/dir");
我只想将这些字符串加粗:Product Version, Java, Runtime, System, User directory
?最简单的方法是什么?
更新
我还测试了这段代码:
TextArea dataPane = new TextArea();
dataPane.setPrefRowCount(10);
Text wd = new Text("Version");
wd.setFont(Font.font ("Verdana", FontWeight.BOLD, 20));
dataPane.appendText(wd + "1.0");
dataPane.appendText("\nJava: " + "7");
dataPane.appendText("\nRuntime: " + "7");
dataPane.appendText("\nSystem: " + "Linux");
dataPane.appendText("\nUser directory: " + "/home/dir");
我明白了:Text@149e84241.0
文本格式不正确。