title: JavaFX - how to know if cancel was pressed
body: <p>How can I know if the OK or the Cancel Button was pressed in this JavaFX dialog.</p>
  
  <p>The Dialog Code:</p>
  
  <pre><code>public String delimiter;
  
  public void delimiterYES() throws IOException {
      delimiter=new String();
      TextInputDialog dialog = new TextInputDialog();
      dialog.setTitle("Delimiter");
      dialog.setHeaderText("Enter the delimiter");
  
      Optional&lt;String&gt; result = dialog.showAndWait();
      if (result.isPresent()) {
          delimiter=result.get();
      }
  }
  </code></pre>