title: Regex for javafx spinner control
body: <pre><code>SpinnerValueFactory svf = new SpinnerValueFactory.DoubleSpinnerValueFactory(-500,500,1,0.5);
  spiKolicina.setValueFactory(svf);
  spiKolicina.setEditable(true);
  
  
  UnaryOperator&lt;TextFormatter.Change&gt; filter = new UnaryOperator&lt;TextFormatter.Change&gt;() {
  
      @Override
      public TextFormatter.Change apply(TextFormatter.Change t) {
  
          if (t.isReplaced())
              if(t.getText().matches("[^0-9]"))
                  t.setText(t.getControlText().substring(t.getRangeStart(), t.getRangeEnd()));
  
  
          if (t.isAdded()) {
              if (t.getControlText().contains(".")) {
                  if (t.getText().matches("[^0-9]")) {
                      t.setText("");
                  }
              }
  
  
              else if (t.getText().matches("[^0-9.]")) {
                  t.setText("");
              }
          }
  
          return t;
      }
  };
  
  
  spiKolicina.getEditor().setTextFormatter(new TextFormatter&lt;&gt;(filter));
  </code></pre>
  
  <p>How to alter regex expression to allow me to enter negative double number in spinner textfield?</p>
  
  <p>Also when the spinner textfield is empty and you press the up or down btn it gives nullPointException, i would like it to go to some default value</p>