import java.awt.*;
import javax.swing.*;
import java.awt.event.*;

class Observer implements ActionListener {
    public Observer() {

    }

    public void actionPerformed(ActionEvent evt) {
        String name = evt.getActionCommand();
        JPanel f = (JPanel)((JButton)evt.getSource()).getParent();


        if (name == "Jaune") {
            f.setBackground(Color.YELLOW);
        } else if (name == "Cyan") {
            f.setBackground(Color.CYAN);
        } else if (name == "Magenta") {
            f.setBackground(Color.MAGENTA);
        }
    }
}

public class Fond {

    public static void main(String[] args) {
        JFrame f = new JFrame("Fond");
        f.setSize(200, 200);
        f.setLocation(100, 100);
        f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        f.setLayout(new GridLayout(1, 3));

        JButton b1 = new JButton("Jaune");
        JButton b2 = new JButton("Cyan");
        JButton b3 = new JButton("Magenta");

        Observer observer = new Observer();

        b1.addActionListener(observer);
        b2.addActionListener(observer);
        b3.addActionListener(observer);

        f.add(b1);
        f.add(b2);
        f.add(b3);

        f.setVisible(true);
    }
}