【问题标题】:When running the program in netBeans the font looks extremely weird在 netBeans 中运行程序时,字体看起来非常奇怪
【发布时间】:2021-06-27 16:54:39
【问题描述】:

我在我的新 MacBook M1 上设置了 netBeans 和 SceneBuilder,一切正常,除了运行程序时的字体。

看起来像这样:

我不知道为什么。 按钮应该说:“点击我”和标签:“你好”。

我得到的错误信息是:

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:].

【问题讨论】:

  • 所以我让它以正确的方式工作。我将 SceneBuilder 中的字体更改为“SansSerif”,现在它显示了应该显示的文本。但我仍然收到一个警告:Loading FXML document with JavaFX API of version 16 by JavaFX runtime of version 11.0.2
  • 好的,所以我也修复了它。在我的 FXML 中,我输入: xmlns="javafx.com/javafx" xmlns:fx="javafx.com/fxml/1" 而不是 xmlns="javafx.com/javafx/16" xmlns:fx="javafx.com/fxml/1"

标签: java netbeans fonts scenebuilder


【解决方案1】:

我也遇到了同样的问题,但就我而言,问题出在 JDK 11。首先,我尝试切换到 JDK 8,一切正常,但后来我发现另一个版本的 JDK 11(AdoptOpenJDK(HotSpot ) 11) 也修复了它。

【讨论】:

    【解决方案2】:

    在我的情况下,我使用 JavaFX 11 和 JDK11,这给出了奇怪的字符,所以我将它更改为 JavaFX 16 并开始使用 JDK16,这解决了我的问题!

    【讨论】:

      【解决方案3】:

      我还将我的模块设置切换回:11.0.8 而不是 11.0.12,如下所示:

      【讨论】:

      • 对于问题和答案,请将整个文档和屏幕截图保留在此站点上。如果另一个人倒下,这篇文章将毫无用处。
      • 请添加更多详细信息以扩展您的答案,例如工作代码或文档引用。
      【解决方案4】:

      在我的情况下,当我在 mac 上运行 programm 时出现了垃圾(在 pc 上都很好)。

      对我来说,解决这个问题的最短方法是样式表中的一条记录:

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

      【讨论】:

        【解决方案5】:

        我可以通过调整 JDK 版本来解决这个问题。虽然我没有 JDK 8,但 JDK 14 运行良好,而 JDK 17 没有。如果您将项目结构更改为与 JavaFX 更兼容的 JDK 版本,它将正常工作。

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 2014-03-04
          • 1970-01-01
          • 2015-12-07
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2014-07-29
          相关资源
          最近更新 更多