You have to return a Scene from another method or create a Scene within the "Start", and set the Scene on stage. For example:
public static Scene secondScene(final Stage primaryStage){
BorderPane pane = new BorderPane();
Label l = new Label("Second Scene");
pane.setCenter(l);
//let's say I have a button that changes back to original stage
Button b = new Button("Main stage");
b.setOnAction(new EventHandler<ActionEvent>(){
public void handle(ActionEvent t){
// create your own Scene and then set it to primaryStage
primaryStage.setScene(new Scene ... );
}
});
return new Scene(pane, 300, 300);
}
Then on your start method:
@Override
public void start(Stage primaryStage){
BorderPane mainPane = new BorderPane();
Button b = new Button("Register");
mainPane.setCenter(b);
b.setOnAction(new EventHandler<ActionEvent>(){
public void handle(ActionEvent t){
primaryStage.setScene(secondScene(primaryStage));
}
});
primaryStage.setScene(new Scene(mainPane, 300,300));
primaryStage.show();
}
This will change to "SecondScene" when the button is pressed.
EDIT ////////////////////////////////////////
BASICALLY:
you need to pass in primaryStage as an argument to SecondScene in order to set another Scene onto it.
What you could do in this case is, make a method that outputs the main scene and then set it using that.
public static Scene mainScene(final Stage primaryStage){
.....
return new Scene(...);
}