Set Font globally in JavaFX

后端 未结 3 1679
攒了一身酷
攒了一身酷 2020-12-09 11:00

How can I set the Font type globally in a JavaFX application?

Is there any solution that I can use? In JavaFX 8 the default Font has changed, and I would like to us

3条回答
  •  眼角桃花
    2020-12-09 11:25

    You can skin your application with CSS as described on the Oracle Website. Using following syntax you may set the general theme for your application:

    .root{
        -fx-font-size: 16pt;
        -fx-font-family: "Courier New";
        -fx-base: rgb(132, 145, 47);
        -fx-background: rgb(225, 228, 203);
    }
    

    You include the css as followed:

    scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
    

提交回复
热议问题