Numeric TextField for Integers in JavaFX 8 with TextFormatter and/or UnaryOperator : <p>I am trying to create a numeric TextField for Integers by using the TextFormatter of JavaFX 8.</p>

<p><strong>Solution with UnaryOperator:</strong></p>

<pre><code>UnaryOperator&lt;Change&gt; integerFilter = change -&gt; {
    String input = change.getText();
    if (input.matches("[0-9]*")) { 
        return change;
    }
    return null;
};

myNumericField.setTextFormatter(new TextFormatter&lt;String&gt;(integerFilter));
</code></pre>

<p><strong>Solution with IntegerStringConverter:</strong></p>

<pre><code>myNumericField.setTextFormatter(new TextFormatter&lt;&gt;(new IntegerStringConverter()));  
</code></pre>

<p>Both solutions have their own problems. With the UnaryOperator, I can only enter digits from 0 to 9 like intended, but I also need to enter negative values like "-512", where the sign is only allowed at the first position. Also I don't want numbers like "00016" which is still possible.</p>

<p>The IntegerStringConverter method works way better: Every invalid number like "-16-123" is not accepted and numbers like "0123" get converted to "123". But the conversion only happens when the text is commited (via pressing enter) or when the TextField loses its focus.</p>

<p>Is there a way to enforce the conversion of the second method with the IntegerStringConverter every time the value of the TextField is updated?</p>
