2023-04-27 11:24:21 +02:00
|
|
|
import javax.swing.*;
|
|
|
|
import java.awt.*;
|
|
|
|
import java.awt.event.*;
|
|
|
|
|
|
|
|
public class Fond extends JPanel implements ActionListener {
|
|
|
|
|
2023-05-09 11:23:33 +02:00
|
|
|
int etat = 0;
|
|
|
|
|
|
|
|
public Fond()
|
|
|
|
{
|
2023-04-27 11:24:21 +02:00
|
|
|
super();
|
|
|
|
JButton bouton = new JButton("Blue");
|
|
|
|
this.add(bouton);
|
|
|
|
JButton bouton2 = new JButton("Red");
|
|
|
|
this.add(bouton2);
|
|
|
|
JButton bouton3 = new JButton("Green");
|
|
|
|
this.add(bouton3);
|
|
|
|
|
|
|
|
bouton.addActionListener(this);
|
|
|
|
bouton2.addActionListener(this);
|
|
|
|
bouton3.addActionListener(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void actionPerformed(ActionEvent e)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (e.getActionCommand()=="Blue") {
|
|
|
|
this.setBackground(Color.BLUE);
|
2023-05-09 11:23:33 +02:00
|
|
|
this.etat = 1;
|
2023-04-27 11:24:21 +02:00
|
|
|
}
|
|
|
|
if (e.getActionCommand()=="Red") {
|
|
|
|
this.setBackground(Color.RED);
|
2023-05-09 11:23:33 +02:00
|
|
|
this.etat = 2;
|
2023-04-27 11:24:21 +02:00
|
|
|
}
|
|
|
|
if (e.getActionCommand()=="Green") {
|
|
|
|
this.setBackground(Color.GREEN);
|
2023-05-09 11:23:33 +02:00
|
|
|
this.etat = 3;
|
2023-04-27 11:24:21 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|