2010-06-25 107 views

回答

6

这取决于JavaFX的版本,我想这大约是1.3。
默认情况下,ListView显示toString()的结果应用于存储在其变量items中的对象。
但是你可以定义一个cellFactory功能,将产生一个ListCell这需要这些对象,并提出在Node控股不管你把,例如TextLabel,或更复杂的东西。那么,在那里,您可以按照通常的方式格式化文本。现在

,如果你不想去的详细程度,只要使用CSS:

.list-cell 
{ 
    -fx-font: 18pt "Arial"; 
} 
0

另一种解决方案,直接的方法:

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); 
      } 
     }