It must be a very simple thing to do perhaps but some how none of the solutions worked for me so far. So finally the question, maybe something that I didn't take in account.
I want to load FXML with its controller from sub package of the start class in Netbeans project. Tried all the solutions here referring to many different questions already, still didn't work.
The package structure:
Source Pacakge
-a
-b
-c
-d
StartUp_Classs.java
-ui
FXMLDocument.fxml
FXMLDocumentController.java
Here is the start method:
@Override
public void start(Stage stage) throws Exception {
try {
setUserAgentStylesheet(STYLESHEET_MODENA);
FXMLLoader loader = new FXMLLoader();
Parent root = (Parent) loader.load(getClass().getResourceAsStream("/ui/FXMLDocument.fxml"));
final FXMLDocumentController controller = (FXMLDocumentController) loader.getController();
stage.addEventHandler(WindowEvent.WINDOW_SHOWN, controller::handleWindowShownEvent);
stage.addEventHandler(WindowEvent.WINDOW_SHOWING, controller::handleWindowShowingEvent);
Scene scene = new Scene(root);
stage.setScene(scene);
stage.setResizable(false);
stage.toFront();
stage.setTitle("Simple FXML");
stage.getIcons().add(new Image(getClass().getResourceAsStream("/resources/images/Orange.jpg")));
stage.show();
} catch (IOException iOException) {
iOException.printStackTrace();
}
}
Any suggestions, would be a great help.