title: Java: how to allow backspace being pressed in JTextField
body: <p>I've made a JTextField that restricts characters being entered unless it's numbers, letter "e", or comma . But now I realised that it restricts backspace being pressed to. How can I change it? I'll add the code, where it checks what key is being pressed, below</p>
  
  <pre><code>for (JTextField tf : listOfFields)
           {
               String value = tf.getText();
               int n = value.length();
               if (ke.getKeyChar()&gt;= '0' &amp;&amp;  ke.getKeyChar() &lt;= '9' || ke.getKeyChar() == ','|| ke.getKeyChar() == 'e')
               {
                   tf.setEditable(true);
               }
               else
               {
                 tf.setEditable(false);
               }
           }}});
  </code></pre>