title: JavaFX: Red border for text field
body: <p>I have a form with text fields and I want to give them a red border if I click on "save" but e.g. nothing was input in required fields, letters for the "birthday" field,... .</p>
  
  <p>My files:
  EditController.java, error.css</p>
  
  <p>I already tried:</p>
  
  <pre><code>tfFirstName.getStyleClass().add("error");
  </code></pre>
  
  <p>, to remove it if they enter something valid:</p>
  
  <pre><code>tfFirstName.getStyleClass().remove("error");
  </code></pre>
  
  <p>and in the css:</p>
  
  <pre><code>.text-field.error {  
   -fx-border-color: red ;  
   -fx-border-width: 2px ;  
  }
  </code></pre>
  
  <p>But it didn't change anything.</p>
  
  <p>Surprisingly, </p>
  
  <pre><code>tfFirstName.setStyle("-fx-border-color: red ; -fx-border-width: 2px ;");
  </code></pre>
  
  <p>(and an empty string to get rid of it) works just fine but it isn't "pretty" if I want to add more to it later.</p>
  
  <p>Does anyone know how to fix the css?</p>