title: JButton and ActionListener producing several exceptions in java.awt, security, and event?
body: <p>I have four buttons at east, west, north and south, and I'm trying to have the button that is pressed change it's text.  In Eclipse it seems problem-less before compiling, but when I do compile and try to press any of the four buttons, it displays many exceptions.</p>
  
  <pre><code>import java.awt.event.*;
  import java.awt.*;
  import javax.swing.*;
  
  public class gui {
      JButton rightbutton;
      JButton leftbutton;
      JButton downbutton;
      JButton upbutton;
  
      public static void main(String[] args) {
          gui GUI = new gui();
          GUI.go();
      }
  
      public void go() {
          JFrame myFrame = new JFrame("The Gui");
          JPanel myPanel = new JPanel();
  
          JButton rightbutton = new JButton("Right Button");
          rightbutton.addActionListener(new rightListener());
          JButton leftbutton = new JButton ("Button of the west");
          leftbutton.addActionListener(new leftListener());
          JButton downbutton = new JButton ("Button on the bottom");
          downbutton.addActionListener(new downListener());
          JButton upbutton = new JButton ("Button in the sky");
          upbutton.addActionListener(new upListener());   
  
          myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
          myFrame.setSize(500,500);
          myFrame.setVisible(true);
  
          myFrame.getContentPane().add(myPanel);
          myFrame.getContentPane().add(BorderLayout.EAST,rightbutton);
          myFrame.getContentPane().add(BorderLayout.NORTH,upbutton);
          myFrame.getContentPane().add(BorderLayout.SOUTH,downbutton);
          myFrame.getContentPane().add(BorderLayout.WEST,leftbutton);
      }
          class rightListener implements ActionListener {
              public void actionPerformed(ActionEvent event) {
                  rightbutton.setText("Pushed");
              }
          }
          class leftListener implements ActionListener {
              public void actionPerformed(ActionEvent event) {
                  leftbutton.setText("Pushed");
              }
          }
          class downListener implements ActionListener {
              public void actionPerformed(ActionEvent event) {
                  downbutton.setText("Pushed");
              }
          }
          class upListener implements ActionListener {
              public void actionPerformed(ActionEvent event) {
                  upbutton.setText("Pushed");
              }
          }
  }
  </code></pre>
  
  <p>Here are all of the exceptions that are given when I press any of the four buttons.</p>
  
  <pre><code>Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
      at gui$leftListener.actionPerformed(gui.java:46)
      at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
      at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
      at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
      at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
      at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
      at java.awt.Component.processMouseEvent(Unknown Source)
      at javax.swing.JComponent.processMouseEvent(Unknown Source)
      at java.awt.Component.processEvent(Unknown Source)
      at java.awt.Container.processEvent(Unknown Source)
      at java.awt.Component.dispatchEventImpl(Unknown Source)
      at java.awt.Container.dispatchEventImpl(Unknown Source)
      at java.awt.Component.dispatchEvent(Unknown Source)
      at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
      at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
      at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
      at java.awt.Container.dispatchEventImpl(Unknown Source)
      at java.awt.Window.dispatchEventImpl(Unknown Source)
      at java.awt.Component.dispatchEvent(Unknown Source)
      at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
      at java.awt.EventQueue.access$200(Unknown Source)
      at java.awt.EventQueue$3.run(Unknown Source)
      at java.awt.EventQueue$3.run(Unknown Source)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
      at java.awt.EventQueue$4.run(Unknown Source)
      at java.awt.EventQueue$4.run(Unknown Source)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
      at java.awt.EventQueue.dispatchEvent(Unknown Source)
      at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
      at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
      at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
      at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
      at java.awt.EventDispatchThread.run(Unknown Source)
  Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
      at gui$upListener.actionPerformed(gui.java:56)
      at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
      at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
      at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
      at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
      at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
      at java.awt.Component.processMouseEvent(Unknown Source)
      at javax.swing.JComponent.processMouseEvent(Unknown Source)
      at java.awt.Component.processEvent(Unknown Source)
      at java.awt.Container.processEvent(Unknown Source)
      at java.awt.Component.dispatchEventImpl(Unknown Source)
      at java.awt.Container.dispatchEventImpl(Unknown Source)
      at java.awt.Component.dispatchEvent(Unknown Source)
      at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
      at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
      at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
      at java.awt.Container.dispatchEventImpl(Unknown Source)
      at java.awt.Window.dispatchEventImpl(Unknown Source)
      at java.awt.Component.dispatchEvent(Unknown Source)
      at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
      at java.awt.EventQueue.access$200(Unknown Source)
      at java.awt.EventQueue$3.run(Unknown Source)
      at java.awt.EventQueue$3.run(Unknown Source)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
      at java.awt.EventQueue$4.run(Unknown Source)
      at java.awt.EventQueue$4.run(Unknown Source)
      at java.security.AccessController.doPrivileged(Native Method)
      at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
      at java.awt.EventQueue.dispatchEvent(Unknown Source)
      at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
      at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
      at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
      at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
      at java.awt.EventDispatchThread.run(Unknown Source)
  </code></pre>