Is there a way to keep my scenes in separate Java files in a JavaFx application? I tried something like this:
public class MyApp extends Application
{
private void init(Stage primaryStage)
{
Group root = new Group();
primaryStage.setResizable(false);
Login login = new Login(root, primaryStage); // from another file
primaryStage.setScene(login);
}
I have to close my login scene after authentication and load another scene from another file, so I'm passing the primaryStage
as a parameter for my login Scene
to use stage.close()
Is there a better way for doing that?
My Login scene file
public class Login extends Scene
{
public Login(Group root, final Stage stage)
{
super(root, 265, 390, Color.web("EBE8E3"));
Is there another way to reference the current scene stage?