enter image description hereI am opening a Login JavaFX page from UserController.java and it has its control in LoginController.java.After processing it in LoginController.java and I am executing a close method to close the stage declared in UserController(which contains the stage for Login) but it throws NullPointerException
public class UserMenuController {
@FXML
private MenuItem Login;
Stage loginStage;
public void LoginPage(ActionEvent actionEvent) throws IOException {
loginStage=new Stage();
Parent loginFXML=FXMLLoader.load(getClass().getResource("/login.fxml"));
loginStage.setTitle("Login");
Scene loginScene=new Scene(loginFXML);
loginStage.setScene(loginScene);
loginStage.show();
}
public void shutLoginStage(){
loginStage.close();
}
}
public class LoginController implements Initializable {
@FXML
private WebView view;
UserMenuController u=new UserMenuController();
public void initialize(URL location, ResourceBundle resources) {
view.getEngine().load("https://kite.trade/connect/login?v=3&api_key=kpnnt4xthv187j8p");
view.getEngine().getLoadWorker().stateProperty().addListener((observable, oldValue, newValue) -> {[enter image description here][1]
//Gets the URL Request Token
if (newValue.equals(Worker.State.FAILED)) {
//System.out.println(view.getEngine().getLocation());
System.out.println(view.getEngine().getLocation());
u.shutLoginStage();
}
});