Hello , I want to create a javafx TextField where the user can only input in the current order A11111111A : <p>So the first and last input should be letters, and between them should be only numbers. Here is my code : </p>

<pre><code>tf.textProperty().addListener(new ChangeListener&lt;String&gt;() {
        public void changed(final ObservableValue&lt;? extends String&gt; ov, final String oldValue, final String newValue) {

            String text_of_first_letter = tf.getText().substring(0, 1);
            if (tf.getText().length() &gt; 1 ) {

                if(!newValue.matches("\\d*")) {

                    tf.setText(newValue.replaceFirst("[^\\d]", ""));
                }

            }
            else if(tf.getText().length() == 1){
                System.out.println("ktu");
                tf.setText(newValue.replaceFirst("[^\\d]", text_of_first_letter));
            }
        }
    });
</code></pre>
