I want to change UI screens from login.fxml
to home.fxml
.
Should I change the Stage
or the Scene
? I'm not sure which is the best practice?
Also, can I use a lambda expression for the handler in the controller?
First, let's start out with the Stage
.vs. Scene
issue:
As known, the JavaFX
hierarchy is based on: Stage
-> Scene
-> Nodes
(etc).
See here:
Practically speaking, a rule-of-thumb in my opinion is the future:
If you plan on going forward to a different place in the flow of your program (login -> profile, for example) - change the Stage
.
If you are in the same enviroment (login for the first time -> login after multiple wrong tries) - change the Scene
.
As for lambdas: Ahhmmm... if your current Java
/JavaFX
version has the abillity - there is no reason not to use.
For more about controller handlers in
Java 8, see this great tutorial.