2
I created a login screen that when authenticating redirects to the menu, but calling by the controller does not work.
Main:
public class Main extends Application {
@Override
public void start(Stage primaryStage) throws IOException {
Parent root = FXMLLoader.load(getClass().getResource("view/Login.fxml"));
Scene scene = new Scene(root);
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
Logincontroller:
@FXML
void logar(ActionEvent event) throws IOException {
if (LoginDao.autenticar(text_usuario.getText(), text_senha.getText())) {
Parent blah = FXMLLoader.load(getClass().getResource("view/Menu.fxml"));
Scene scene = new Scene(blah);
Stage appStage = (Stage) ((Node) event.getSource()).getScene().getWindow();
appStage.setScene(scene);
appStage.show();
} else {
System.out.println("login ou senha incorretos");
}
}
I’ve tried instantiating Main in the controller to access primaryStage and nothing, how could I perform this screen swap? alias I started messing today with javafx this would be the most practical way?