title: How to trigger an event on enter key press in JTextField in java
body: <p>I have a button and a JTextField and if the JTextField is empty a message window opens informing that the field is empty.
  Now I want when I enter a number inside the JTextField, the text on the button to change.
  But I don't know which code to use.</p>
  
  <p>I used this code</p>
  
  <pre><code>               tfInputTinter.addActionListener(new ActionListener() {
  
                      @Override
                      public void actionPerformed(ActionEvent e) {
                          btObserving.setText("Stop Observing");
                      }
                  });
  </code></pre>
  
  <p>but nothing happens with the text on the button.
  Does anybody have an idea what should I do?
  Thanks</p>