title: getActionCommand with .equal not equaling properly
body: <p>I'm trying to learn Jtextfields and action listeners. I was following this tutorial <a href="https://www.geeksforgeeks.org/java-swing-jtextfield/" rel="nofollow noreferrer">https://www.geeksforgeeks.org/java-swing-jtextfield/</a>, but I'm encountering an error with this function.</p>
  <pre><code>public void actionPerformed(ActionEvent e) {
      String input = e.getActionCommand();
      if (input.equals(&quot;submit&quot;)) {
          displaysText.setText(textField.getText());
          textField.setText(&quot;&quot;);
          System.out.println(&quot;Entered if statement&quot;);
      }
  }
  </code></pre>
  <p>No matter what I input into the text field it will enter that if statement. It should just enter that if statement when I enter &quot;submit&quot;. Is this a bug or am I doing something wrong?</p>
  <p>If it's any help here is all of the code</p>
  <pre><code>package IncludesMain;
  
  import java.awt.event.*;
  import javax.swing.*;
  
  public class Main extends JFrame implements ActionListener {
      static JTextField textField;
      static JFrame frame;
      static JButton button;
      static JLabel displaysText;
      Main() {}
  
      public static void main(String[] args) {
  
          frame = new JFrame(&quot;textfield&quot;);
          displaysText = new JLabel(&quot;N/A&quot;);
          button = new JButton(&quot;submit&quot;);
  
          Main textObject = new Main();
          button.addActionListener(textObject);
          textField = new JTextField(16);
          JPanel panel = new JPanel();
  
          panel.add(textField);
          panel.add(button);
          panel.add(displaysText);
  
          frame.add(panel);
          frame.setSize(500, 400);
          frame.show();
  
  
      }
  
      public void actionPerformed(ActionEvent e) {
          String input = e.getActionCommand();
          if (input.equals(&quot;submit&quot;)) {
              displaysText.setText(textField.getText());
              textField.setText(&quot;&quot;);
              System.out.println(&quot;Entered if statement&quot;);
          }
      }
  }
  </code></pre>