In this programm i wanna switch between scenes by button click.I get an Exception on the line where i want to set the Location of the FXML Loader. In other Tutorials or posts i see it is done in the same way i did it.I also checked the Path to the fxml file a hundred times.
So the special case is to switch from QuestionTableViewController with the fxml of tableViewQuestion.fxml to the tableViewUser.fxml with the Controller UserTableViewController. At least i start the Programm in MyApplication.
Could that Exception arrive, because my Class is implementimg initializable? And if yes why and how to fix this? Or maybe because i have different Controllers for the fxml-files? but why and how could i fix this?
So now i ask you, where is my dumb fault at that Programm?
Controller with the switchMethod:
public class QuestionTableViewController implements Initializable{
@FXML
TableView<Question> questionTable;
public void changeToUserDatabase() throws IOException {
Scene quizScene = new Scene(FXMLLoader.load(getClass().
getResource("src/view/tableViewUser.fxml")));
Stage primaryStage = (Stage) questionTable.getScene().getWindow();
primaryStage.setScene(quizScene);
primaryStage.show();
}}
Start Method:
public class MyApplication extends Application {
@Override
public void start(Stage primaryStage) throws Exception{
Parent root = FXMLLoader.load(getClass().getResource("view/tableViewQuestion.fxml"));
primaryStage.setTitle("Database of Century");
primaryStage.setScene(new Scene(root, 750, 500));
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
PS: I just show the methods i think are needed, of course i had a button with the onMouseClick method and a content for my tableView. If you think they could be relevant please commit and i will add it in the question. :)