问题描述
我尝试了这个建议但无法找到样式。
I tried this suggestion http://forums.sun.com/thread.jspa?threadID=5421037 but style cannot be found.
还有其他方法吗?
非常感谢,
cancelledout
Lots of thanks,cancelledout
推荐答案
它取决于JavaFX的版本,我认为它大约是1.3。
默认情况下, ListView
显示 toString的结果()
应用于存储在 items
变量中的对象。
但是你可以定义一个 cellFactory
将生成 ListCell
的函数,它接收这些对象并以节点
持有你输入的内容,例如 Text
或 Label
,或更复杂的东西。所以,在那里,你可以按照常规的方式格式化文本。
It depends on the version of JavaFX, I will suppose it is about 1.3.
By default, ListView
shows the result of toString()
applied to the objects stored in its items
variable.
But you can define a cellFactory
function that will generate a ListCell
that takes these objects and presents in a Node
holding whatever you put in, for example a Text
or Label
, or something more complex. So, there, you can format the text the usual way.
现在,如果你不想达到那个级别的细节,那就用CSS:
Now, if you don't want to go to that level of detail, just use CSS:
.list-cell
{
-fx-font: 18pt "Arial";
}
这篇关于如何在JavaFX中更改ListView中的字体大小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!