简体   繁体   English

在 netBeans 中运行程序时,字体看起来非常奇怪

[英]When running the program in netBeans the font looks extremely weird

I set up netBeans and a SceneBuilder on my new MacBook M1 and everything works, except of the font when running the program.我在我的新 MacBook M1 上设置了 netBeans 和 SceneBuilder 并且一切正常,除了运行程序时的字体。

It looks like this:它看起来像这样:

https://i.stack.imgur.com/8Yads.png

and I have no clue why.我不知道为什么。 The Button should say: "Click me" and the Label: "Hello".按钮应该说:“点击我”和 Label:“你好”。

The Error message I get is:我得到的错误信息是:

März 31, 2021 6:33:04 PM javafx.fxml.FXMLLoader$ValueElement processValue
WARNING: Loading FXML document with JavaFX API of version 16 by JavaFX runtime of version 11.0.2
2021-03-31 18:33:05.466 java[4349:140717] CoreText note: Client requested name ".SFNS-Regular", it will get Times-Roman rather than the intended font. All system UI font access should be through proper APIs such as CTFontCreateUIFontForLanguage() or +[NSFont systemFontOfSize:].
2021-03-31 18:33:05.466 java[4349:140717] CoreText note: Set a breakpoint on CTFontLogSystemFontNameRequest to debug.
2021-03-31 18:33:05.471 java[4349:140717] CoreText note: Client requested name ".SFNS-Regular", it will get Times-Roman rather than the intended font. All system UI font access should be through proper APIs such as CTFontCreateUIFontForLanguage() or +[NSFont systemFontOfSize:].
2021-03-31 18:33:05.641 java[4349:140751] CoreText note: Client requested name ".SFNS-Regular", it will get Times-Roman rather than the intended font. All system UI font access should be through proper APIs such as CTFontCreateUIFontForLanguage() or +[NSFont systemFontOfSize:].

I also had the same issue, but in my case, the problem was with JDK 11. First, I tried to switch to JDK 8 and everything worked fine, but then I found that another version of JDK 11 (AdoptOpenJDK(HotSpot) 11) also fixes it.我也遇到了同样的问题,但就我而言,问题出在 JDK 11 上。首先,我尝试切换到 JDK 8,一切正常,但后来我发现另一个版本的 JDK 11 (AdoptOpenJDK(HotSpot) 11)也修复它。

In my case that crap came up when I run programm on mac (on pc was all good).就我而言,当我在mac上运行programm时出现了垃圾(在pc上一切都很好)。

For me shortest way to solve this was one record in stylesheet:对我来说,解决这个问题的最短方法是样式表中的一条记录:

.root{
-fx-font-size: 11pt;
-fx-font-family: "Arial";
}

In my case, I was using the JavaFX 11 with the JDK11 and that was giving the weird characters, so I changed it to JavaFX 16 and also started using the JDK16 and that fixed my problem!在我的情况下,我使用 JavaFX 11 和 JDK11 并且给出了奇怪的字符,所以我将其更改为 JavaFX 16 并开始使用 JDK16 并解决了我的问题!

I have also switched my Module setting back to: 11.0.8 instead of 11.0.12 as shown below:我还将我的模块设置切换回:11.0.8 而不是 11.0.12,如下所示:

在此处输入图像描述

I was able to resolve the issue by adjusting the JDK version.我可以通过调整 JDK 版本来解决这个问题。 Although I did not have JDK 8, JDK 14 worked fine and JDK 17 did not.虽然我没有 JDK 8,但 JDK 14 运行良好,而 JDK 17 没有。 It will work fine if you change the project structure to a more compatible JDK version with JavaFX.如果您将项目结构更改为与 JavaFX 更兼容的 JDK 版本,它将正常工作。

I fixed everything just check my comments.我修复了所有问题,只需检查我的评论。

You can install the AdoptOpenJDK from this link https://formulae.brew.sh/cask/adoptopenjdk ( you need to have Brew installed ).您可以从此链接https://formulae.brew.sh/cask/adoptopenjdk 安装 AdoptOpenJDK您需要安装 Brew )。

Then you go to the project module settings and then go to project.然后你 go 到项目模块设置,然后 go 到项目。 There you will see the label SDK.在那里你会看到 label SDK。 Click there and next add JDK.单击那里,然后添加 JDK。 It will redirect you to the JDKs and next select the AdoptOpenJDk folder.它会将您重定向到 JDK,然后将 select 重定向到 AdoptOpenJDk 文件夹。

I am having this same issue.我有同样的问题。 How did you change the font in Scene Builder?您是如何更改 Scene Builder 中的字体的? I don't see that option anywhere:(我在任何地方都看不到该选项:(

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM