I want to do something basic; when a button is pressed, go to a new view (scene?). I want this new view to be in its own class. I assume that to do this, I need to make a class that extends Scene
. Doing this, I'm forced to implement the following constructor:
public Test(@NamedArg("root") Parent root) {
super(root);
}
Let's call the first view Scene A
and the second one Scene B
. I assume that Scene A will be the parent - so I will need to call Scene B's constructor in A after, say, a button is clicked. To do that (from what I've read), I need a line like this in Scene A's class:
Parent root = FXMLLoader.load(getClass().getResource("FXML/SceneA.fxml"));
However, I can't find any examples without an fxml class. I am not familiar with it and want to use pure Java code for the time being. Is there a Java version of this?
Am I approaching this the wrong way? Any advice is very much appreciated.