4

I set up netBeans and a SceneBuilder on my new MacBook M1 and everything works, except of the font when running the program.

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".

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:].
Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
  • 1
    so I made it work the right way. I changed the font in the SceneBuilder to "SansSerif" and now it displays the text as it should be displayed. But I still get one warning: Loading FXML document with JavaFX API of version 16 by JavaFX runtime of version 11.0.2 –  Mar 31 '21 at 16:54
  • okay, so I also fixed it. In my FXML I put: xmlns="http://javafx.com/javafx" xmlns:fx="http://javafx.com/fxml/1" instead of xmlns="http://javafx.com/javafx/16" xmlns:fx="http://javafx.com/fxml/1" –  Mar 31 '21 at 19:01
  • What was the "right way" -- I am running into this issue currently. Intel MBP - Latest ( Monterey ) - but Im using Intellij CE – R.J. Robinson Apr 29 '22 at 00:46

6 Answers6

5

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.

Kirby
  • 15,127
  • 10
  • 89
  • 104
Alagrom
  • 96
  • 1
  • 4
3

In my case that crap came up when I run programm on mac (on pc was all good).

For me shortest way to solve this was one record in stylesheet:

.root{
-fx-font-size: 11pt;
-fx-font-family: "Arial";
}
  • adding the font-family fixed my issue - i tried a number of different jvms, but the warnings show it's all about the font – paulf May 06 '22 at 03:02
1

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!

Any 07
  • 11
  • 2
1

I have also switched my Module setting back to : 11.0.8 instead of 11.0.12 as shown below:

enter image description here

Tomerikoo
  • 18,379
  • 16
  • 47
  • 61
  • For both question and answer, keep the whole documentation and screenshots on this site. If the other one goes down this post will be useless. – Queeg Sep 03 '21 at 20:59
  • 1
    Please add further details to expand on your answer, such as working code or documentation citations. – Community Sep 03 '21 at 22:29
1

I was able to resolve the issue by adjusting the JDK version. Although I did not have JDK 8, JDK 14 worked fine and JDK 17 did not. It will work fine if you change the project structure to a more compatible JDK version with JavaFX.

Sakhawat
  • 31
  • 4
0

You can install the AdoptOpenJDK from this link https://formulae.brew.sh/cask/adoptopenjdk (Note: you need to have Brew installed).

Then you go to the project module settings and then go to 'Project'. There you will see the label 'SDK'. Click there and next select 'Add JDK'. It will redirect you to the JDKs and next select the 'AdoptOpenJDk' folder.

flyingfishcattle
  • 1,817
  • 3
  • 14
  • 25