2010-06-25 47 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); 
      } 
     }