Javafx-2 – set fonts globally in JavaFX

How do I set font types globally in JavaFX applications?

Is there a solution you can use? In JavaFX 8, the default font has been changed. I want to use the same font used in JavaFX 2.2

Solution

You can use CSS to draw applications as described on the Oracle website

.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 following CSS:

scene.getStylesheets().add(getClass().getResource("application.css").toExternalForm());
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>