我试过这个建议http://forums.sun.com/thread.jspa?threadID=5421037但找不到风格。如何更改JavaFX中ListView的字体大小?
有没有其他办法?
很多感谢的, cancelledout
我试过这个建议http://forums.sun.com/thread.jspa?threadID=5421037但找不到风格。如何更改JavaFX中ListView的字体大小?
有没有其他办法?
很多感谢的, cancelledout
这取决于JavaFX的版本,我想这大约是1.3。
默认情况下,ListView
显示toString()
的结果应用于存储在其变量items
中的对象。
但是你可以定义一个cellFactory
功能,将产生一个ListCell
这需要这些对象,并提出在Node
控股不管你把,例如Text
或Label
,或更复杂的东西。那么,在那里,您可以按照通常的方式格式化文本。现在
,如果你不想去的详细程度,只要使用CSS:
.list-cell
{
-fx-font: 18pt "Arial";
}
另一种解决方案,直接的方法:
ListView listView=new ListView();
if(!listView.getItems().isEmpty())
{
VirtualFlow ch=(VirtualFlow) listView.getChildrenUnmodifiable().get(0);
Font anyfont=new Font("Tahoma",16);
for (int i = 0; i < ch.getCellCount(); i++)
{
Cell cell= ch.getCell(i);
cell.setFont(anyfont);
}
}