3
How can I get my application back to the start menu after pressing ESC
. I can currently use Keyevent only when some component is associated, such as a TextField
, Button
, etc.. I just want to press the Esc without any components being selected and the application goes back to the main menu. Example of how I do (Associating a component):
txtPesquisar.setOnKeyPressed(k -> {
final KeyCombination ENTER = new KeyCodeCombination(KeyCode.ENTER);
if (ENTER.match(k)) {
atualizar();
}
});
What is your main menu? You have multiple screens?
– Math
Yes, I have several screens. My main menu is just a "welcome screen"
– DiegoAugusto
Okay, but you already know how to change the screens, right? It would just be the case to do it through a "shortcut key"?
– Math
Yes, that’s right. When I press a key changes Scene. Scene is instantiated in my Main method that way:
Parent root = FXMLLoader.load(getClass().getResource("frmLogin.fxml"));
 Scene scene = new Scene(root);
– DiegoAugusto
Then I take the
scene
and play in a static variable. And with this variable I manipulate all transitions of scenes from the system– DiegoAugusto