I had already asked a similar question here but it seems It wasn't clear since I had a lot of code in the project and couldn't post it here So please don't mark as duplicate.
Because of that, I then decided to create a new project with just a Label in it to make the code small and clean and also to eliminate other potential suspects of the error I'm getting.
So here is my Java Source code
public class Main extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
Group root = new Group();
Label label = new Label("Sample Label");
label.setId("sampleLabel");
root.getChildren().add(label);
Scene scene = new Scene(root, 300, 275);
scene.getStylesheets().add(getClass().getResource("applicationStyles.css").toExternalForm());
primaryStage.setTitle("Hello World");
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
And this is my css file
/**/
@font-face {
font-family:'Roboto';
src:url("Roboto-Thin.ttf");
}
#sampleLabel{
-fx-font-family: Roboto ;
}
This is the error I'm getting in Intellij Idea
Dec 02, 2015 9:16:34 AM com.sun.javafx.css.StyleManager loadStylesheetUnPrivileged
INFO: Could not load @font-face font [file:/C:/Users/UserName/Desktop/Java8%20projects/TeamViewer/out/production/TeamViewer/sample/Roboto-Thin.ttf]
All the project files are in one package and the font file is also present in the out>production>TeamViewer>sample>Roboto-Thin.ttf. I also upgraded from jdk-8u65 to jdk-8u66
Thanks, any help is greatly appreciated.
Roboto-Thin.ttf
located? – Steeplejackout>production>TeamViewer>sample>Main.class
andout>production>TeamViewer>sample>Roboto-Thin.ttf
– AlibiJava8%20projects
) does that make a difference? What if you package the application in a jar file and run that one? – SteeplejackJava8%20projects
toJava8projects
tends to solve the problem. – Alibi