在JavaFX中全局设置字体 [英] Set Font globally in JavaFX

查看:2849
本文介绍了在JavaFX中全局设置字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在JavaFX应用程序中全局设置Font类型?

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

我可以使用任何解决方案吗?在JavaFX 8中,默认的Font已经改变,我想使用JavaFX 2.2中使用的相同Font。

Is there any solution that I can use? In JavaFX 8 the default Font has changed, and I would like to use the same Font used in JavaFX 2.2.

推荐答案

你可以使用CSS调整应用程序,如在Oracle网站上所述。
使用以下语法,您可以设置应用程序的常规主题:

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);
}

您包含的css如下:

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

这篇关于在JavaFX中全局设置字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆