IntelliJ Idea is giving me this warning:
Argument 'getClass().getClassLoader().getResource( "view/RootLayout.fxml" )' might be null
However, it always works. I just want the clear warning, preferably without annotations or disabling the inspection.
Per this thread: IntelliJ IDEA - getClass().getResource("...") return null
- I have my resources folder set as a Resources Root.
- I added *.fxml to Settings -> Build, Execution, Deployment -> Compiler -> Resource patterns
- I even added ?.fxml and !?.fxml to cover more possibilities.
None of those seem to make any difference.
Here is my start() method:
@Override
public void start( Stage primaryStage ) throws Exception
{
// Load the FXML file containing all of the UI elements.
FXMLLoader loader = new FXMLLoader();
loader.setLocation( getClass().getResource( "view/RootLayout.fxml" ) );
Parent root = FXMLLoader.load( getClass().getClassLoader().getResource( "view/RootLayout.fxml" ) );
// Create the stage and set the window title.
primaryStage.setTitle( "SNMP Link Utilization" );
// Set the scene using root, with the specified width and height.
primaryStage.setScene( new Scene( root, 500, 600 ) );
// Set the icon for a non-Maven build.
//primaryStage.getIcons().add( new Image( "file:resources/images/nic.png" ) );
// Set the icon for a Maven build.
primaryStage.getIcons().add( new Image( "images/nic.png" ) );
primaryStage.show();
}
Am I doing anything wrong? I've tried a few other ways of creating the Parent object, but all that I have tried end up failing.