I am working through the official JavaFX tutorial. I am trying to add the code from Example 5-1 as follows to my scene, which is part of the "Main" class as per the instructions:
Scene scene = new Scene(grid, 300, 275);
primaryStage.setScene(scene);
scene.getStylesheets().add(Login.class.getResource("Login.css").toExternalForm());
primaryStage.show();
I'm using JavaFX runtime version 8.0.72-b15 and IntelliJ IDEA 15.0.5. I have stored my "Login.css" file in the folder:
C:\Users\XXXXXXXX\IdeaProjects\Login\src
and my project files are structured as follows:
- Login
- .idea
- out
- src
- sample
- Controller.java
- Main.java
- sample.fxml
- background.jpg
- Login.css
- sample
When I run "Main" I get the following error message:
Information:Using javac 1.8.0_77 to compile java sources
Information:java: Errors occurred while compiling module 'Login'
Information:6/9/2016 2:04 PM - Compilation completed with 1 error and 0 warnings in 571ms
C:\Users\XXXXXXXX\IdeaProjects\Login\src\sample\Main.java
Error:(69, 36) java: cannot find symbol
symbol: class Login
location: class sample.Main
This answer seems to imply that the custom CSS file should be under the "src" folder, but it doesn't appear to be working for me. How can I get my JavaFX project to import this custom CSS file?