Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change the font size in ListView in JavaFX?

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

like image 216
cancelledout Avatar asked Jan 22 '23 20:01

cancelledout


1 Answers

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";
}
like image 196
PhiLho Avatar answered Jan 29 '23 01:01

PhiLho