0

I created a JavaFX application with the scene builder and wanted to adjust the font size according to the current window height on change. So I thought I could declare my font sizes with "em" and just change the css class ".root" to set the "1em" default on runtime.

I spent already hours with searching the answer but didn't found the solution, hope one of you could help me?

Is there any way to change the css class ".root" in the code during runtime? If no, or if there's a better way I would be glad if you would let me know in the comments. thanks!

YaennuuH
  • 19
  • 2
  • 1
    You can do it with Bindings or changelistener https://stackoverflow.com/questions/23705654/bind-font-size-in-javafx – Raw May 29 '19 at 08:17
  • 2
    The `.root` style class is added to the the root of the `Scene` automatically. You can set the font size inline via the [`style` property](https://openjfx.io/javadoc/12/javafx.graphics/javafx/scene/Node.html#styleProperty()) of that root node. – Slaw May 29 '19 at 08:25
  • Thanks for the answers, I'm going to test that =) – YaennuuH May 29 '19 at 08:29
  • Works, thank you very much! I added now e AnchorPane as root and put a listener on it. In the action function I calculate the font size and add it to the AnchorPane. – YaennuuH May 29 '19 at 09:00

0 Answers0