List of usage examples for javafx.scene Parent getScene
public final Scene getScene()
From source file:gmailclientfx.controllers.LoginController.java
public void btnLogin_click(ActionEvent e) { if (!txtEmail.getText().equals("")) { String email = txtEmail.getText(); if (EmailValidator.getInstance().isValid(email)) { User user = User.getUserByEmail(email); if (!(user == null)) { try { GmailClient.setRefreshToken(user.getRefreshToken()); GmailClient.refreshAccessToken(); Parent loginStage = txtEmail.getParent(); loginStage.getScene().getWindow().hide(); Parent root;/*from ww w . ja v a 2s . co m*/ root = FXMLLoader .load(getClass().getClassLoader().getResource("gmailclientfx/views/Home.fxml")); Stage stage = new Stage(); stage.setTitle("Home"); stage.setOnCloseRequest(new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent e) { Platform.exit(); System.exit(0); } }); stage.setScene(new Scene(root)); stage.show(); } catch (IOException ex) { Logger.getLogger(LoginController.class.getName()).log(Level.SEVERE, null, ex); } } else { try { GmailClient.authorizeUser(); String noviEmail = GmailClient.getEmail(); String noviRefreshToken = GmailClient.getRefreshToken(); User u = User.getUserByEmail(noviEmail); if (u == null) { User.unesiUseraUBazu(new User(noviEmail, noviRefreshToken)); } Parent loginStage = txtEmail.getParent(); loginStage.getScene().getWindow().hide(); Parent root; root = FXMLLoader .load(getClass().getClassLoader().getResource("gmailclientfx/views/Home.fxml")); Stage stage = new Stage(); stage.setTitle("Home"); stage.setScene(new Scene(root)); stage.setOnCloseRequest(new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent e) { Platform.exit(); System.exit(0); } }); stage.show(); } catch (IOException ex) { Logger.getLogger(LoginController.class.getName()).log(Level.SEVERE, null, ex); } } } else { lblStatusMsg.setText("Uneseni email nije validan!"); } } else { lblStatusMsg.setText("Unesite email!"); } }