I am trying to create a function for a button in my FXML, that will put a new scene on the stage.
I have been doing this in my code a few times and it has worked successfully, I copied my code over and it doesn't work, so I'm guessing the issue could be with my directory set-up?
Some insight would be massively appriciated
This is my code where I am trying to change scene:
@FXML Button viewFixtureAndResult;
@FXML
public void resultsAndFixturesScreen() throws IOException {
Parent root = FXMLLoader.load(getClass().getClassLoader().getResource("/viewers/fixturesAndResults.fxml"));
Stage window = (Stage)viewFixtureAndResult.getScene().getWindow();
window.setScene(new Scene(root,1000,600));
}
And this is my file set up:
And my errors:
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.reflect.misc.Trampoline.invoke(MethodUtil.java:71)
at sun.reflect.GeneratedMethodAccessor1.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at sun.reflect.misc.MethodUtil.invoke(MethodUtil.java:275)
at javafx.fxml.FXMLLoader$MethodHandler.invoke(FXMLLoader.java:1771)
... 52 more
Caused by: java.lang.NullPointerException: Location is required.
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3207)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3175)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3148)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3124)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:3104)
at javafx.fxml.FXMLLoader.load(FXMLLoader.java:3097)
at adminView.AdminController.resultsAndFixturesScreen(AdminController.java:115)
... 62 more