import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

/**
 * @author Remi Forax
 *
 */
public class Beurk {

  static class MyActionListener implements ActionListener {
    public MyActionListener(JPanel panel) {
      this.panel=panel;
    }
    public void actionPerformed(ActionEvent event) {
      if (button==event.getSource())
        panel.setBackground(Color.RED);
      else
        panel.setBackground(Color.GREEN);
    }
    private final JPanel panel;
  }

  static JButton button, button2;

  public static void main(String[] args) {
    JPanel panel=new JPanel();
    
    button=new JButton("Rouge");
    button2=new JButton("Vert");
    
    ActionListener l=new MyActionListener(panel);
    button.addActionListener(l);
    button2.addActionListener(l);
    
    panel.add(button);
    panel.add(button2);

    JFrame frame=new JFrame();
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setContentPane(panel);
    frame.setSize(300,200);
    frame.show();
  }
}
