Example usage for javafx.beans.property StringProperty toString

List of usage examples for javafx.beans.property StringProperty toString

Introduction

In this page you can find the example usage for javafx.beans.property StringProperty toString.

Prototype

@Override
public String toString() 

Source Link

Document

Returns a string representation of this StringProperty object.

Usage

From source file:employees.Employees.java

@Override
public void start(Stage stage) throws Exception {
    //        Parent root = FXMLLoader.load(getClass().getResource("MainUI.fxml"));
    //        //w w  w. j  a  v  a  2  s  .com
    //        Scene scene = new Scene(root);
    //        
    //        stage.setScene(scene);
    //        stage.show();
    //new LoginStage();
    Task<String> inittask = inittasks.pingServer();
    StringProperty pingResponse = new SimpleStringProperty();
    StringProperty messages = new SimpleStringProperty();
    pingResponse.bind(inittask.valueProperty());
    messages.bind(inittask.messageProperty());
    inittask.stateProperty().addListener((workerState, oldState, newState) -> {
        if (newState == Worker.State.SUCCEEDED) {
            String response = pingResponse.get();
            JSONObject obj = new JSONObject(response);
            String Status = obj.getString("Status");
            if (Status.equals("OK")) {
                AlertDialog ad = new AlertDialog();
                ad.showDialog(AlertTypes.Types.INFORMATION, "Successfull", "PING OK", "Connection Successfull");
            }
        } else if (newState == Worker.State.CANCELLED) {
            AlertDialog ad = new AlertDialog();
            ad.showDialog(AlertTypes.Types.WARNING, "Operation Aborted", "Operation Aborted",
                    "Task Was Cancelled,The System Will Now Exit");
            System.exit(0);
        } else if (newState == Worker.State.FAILED) {
            StringBuilder errstr = new StringBuilder();
            errstr.append(
                    "An Error Has Occured While Connecting to The Server, A Description of the Error is Shown Below : \n");
            errstr.append(messages.toString());
            AlertDialog ad = new AlertDialog();
            ad.showDialog(AlertTypes.Types.ERROR, "An Error Occurred While Connecting to The Server", "Error",
                    messages.get());
            Optional<ButtonType> response = AlertDialog.showConfirmation(
                    "Unable to Connect to The Server: Would you Like To Review Your Network Settings?",
                    "Connection Settings Review", "Review Connection Settings?");
            if (response.get() == ButtonType.OK) {
                try {
                    new initSettingsStage();
                } catch (IOException ex) {
                    Logger.getLogger(Employees.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
        }
    });
    new Thread(inittask).start();

}