Adam Ren Adam Ren - 4 days ago 4x
CSS Question

Javafx CSS Parsing Error

Hello currently I am working on adding a css file to my application in order to customize the interface more. However I am experiencing an error while parsing the CSS file. The application still runs, but I would like to know if this error may cause problems in the future if I leave it and how do I fix it. Below is the error, CSS file and the import of the CSS file.




-fx-font-size: 20;
-fx-font: Times New Roman;
-fx-background-color: #FDFEFE;


Oct 16, 2016 7:57:20 AM com.sun.javafx.css.parser.CSSParser declaration
WARNING: CSS Error parsing file:[*PC Location]/bin/gameaspects/mapScene.css: Expected '<number>' while parsing '-fx-font' at [3,17]


You need to quote the font name, since it contains spaces, and use -fx-font-family. When you have multiple values for -fx-font it is expecting the first to be the font size (hence it is expecting a number):

.label {
    -fx-font-size: 20;
    -fx-font-family: "Times New Roman";
    -fx-background-color: #FDFEFE;

See the JavaFX CSS documentation for details on font settings.