Reputation: 528
I tried this suggestion http://forums.sun.com/thread.jspa?threadID=5421037 but style cannot be found.
Is there any other way?
Lots of thanks, cancelledout
Upvotes: 4
Views: 6226
Reputation: 2030
Another solution, direct approach:
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);
}
}
Upvotes: 0
Reputation: 41142
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.
Now, if you don't want to go to that level of detail, just use CSS:
.list-cell
{
-fx-font: 18pt "Arial";
}
Upvotes: 8