java JavaFX:更改文本字段中的字体和大小
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32624748/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
JavaFX: Change font and size in a TextField
提问by David
The default font settings in TextField depends on your Windows settings and when they are not the same I encounter display issues. So I want to set the TextField to a specific font and size but I don't know how to do it.
Could you please help me on this ?
TextField 中的默认字体设置取决于您的 Windows 设置,当它们不同时,我会遇到显示问题。所以我想将 TextField 设置为特定的字体和大小,但我不知道该怎么做。
你能帮我解决这个问题吗?
回答by Uluk Biy
Try like this way:
像这样尝试:
TextField tf = new TextField();
tf.setFont(Font.font("Verdana", FontWeight.BOLD, 70));
or for setting a custom font
或用于设置自定义字体
tf.setFont(Font.loadFont("file:resources/fonts/isadoracyr.ttf", 120));