title: How do I change the background color of a JPanel with a JButton?
body: <p>I need to have three buttons in my program (the last one is an exit button and it already works) the other two need to change the color of the <code>JPanel</code> background between blue and red.</p>
  
  <p>I need to know what goes in the <code>AtionListeners</code> so that when the buttons are pressed it changes the background color.</p>
  
  <p>This is the class so far :</p>
  
  <pre><code>package myPackageNameGoesHere;
  
  import java.awt.Dimension;
  import java.awt.Graphics;
  import java.awt.event.ActionEvent;
  import java.awt.event.ActionListener;
  
  import javax.swing.JButton;
  import javax.swing.JPanel;
  
  public class EventPanel extends JPanel {
  private static final long serialVersionUID = 123796234;
  
  private JButton blueButton;
  private JButton redButton;
  private JButton exitButton;
  
  public EventPanel() {
      this.setPreferredSize(new Dimension(200, 300));
  
      this.blueButton = new JButton("Blue");
      this.add(this.blueButton);
  
      this.redButton = new JButton("Red");
      this.add(this.redButton);
  
      this.exitButton = new JButton("Exit");
      this.exitButton.addActionListener(new ExitListener());
      this.add(this.exitButton);
  }
  
  private class BlueListener implements ActionListener {
      @Override
      public void actionPerformed(ActionEvent blue) {
          // What goes here?????
  
      }
  }
  
  private class RedListener implements ActionListener {
      @Override
      public void actionPerformed(ActionEvent red) {
          // What goes here????
  
      }
  }
  private class ExitListener implements ActionListener {
      @Override
      public void actionPerformed(ActionEvent exit) {
          System.exit(0);
      }
  }
  }
  </code></pre>