0

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.

wj1091
  • 159
  • 1
  • 2
  • 5
  • Have a look at my answer to http://stackoverflow.com/questions/32464698/, which is a different question but might give you an idea how to do this. – James_D Aug 13 '16 at 12:15
  • So simple and works like a charm - thanks! – wj1091 Aug 13 '16 at 14:37

0 Answers0