-1

I want to be able to set the width of DataGrid cells, based on the number of pixels each string needs (they do not need to be the same size). I have not come across this on Google so was wondering if it was possible, based on the default font etc. used by TornadoFX. I imagine the library somewhere is keeping track of this

Ben Dent
  • 41
  • 7

1 Answers1

0

I use Text(yourStringHere).boundsInLocal.width + 12 to get semi-accurate results for text length. If I recall correctly, this requires the view/node to dock so a runLater call may be necessary. Also, the 12 offset was simply the number I needed to mimic a label's width and avoid cutoffs. It may be a different number for your use. I also did not test this to see if this scales appropriately in larger strings.

Steph
  • 831
  • 6
  • 19