title: Java Applet NullPointerException
body: <p>I'm working on an Applet, which has a JButton that I want to use to enable another JButton. However, when I press the button, I get the error: Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException. Why is this happening? It seems as though when I run the Applet, the global variables don't get instantiated (i.e. they are all "null"). In another program, everything works fine, and I can't find any difference between the two in terms of implementing this action.</p>
  
  <p>Here is a bit of my code:</p>
  
  <pre><code>public class implementation2 extends Applet implements ActionListener {
    private static final long serialVersionUID = -4370650602318597069L;
    ...
    public JButton coreButton, testButton;
    ...
    public void init() {
      ...
      final JButton testButton = new JButton("Test);
      testButton.addActionListener(this);
      ...
      final JButton coreButton = new JButton("CORE");
      coreButton.addActionListener(this);
      coreButton.setEnabled(false);
      ...
    }
    ...
    public void actionPerformed(final ActionEvent event) {
  
    if(event.getActionCommand() == "Test") {
      coreButton.setEnabled(false);
    }
    ...
  </code></pre>
  
  <p>If anyone can point me in the direction towards fixing my code, that would be greatly appreciated! Thank you!</p>