DEV/DEV2.1/TP7/Fond.java
Simon Saye Babu f922df24d7 TP I/O
2023-05-09 11:23:33 +02:00

40 lines
864 B
Java

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class Fond extends JPanel implements ActionListener {
int etat = 0;
public Fond()
{
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);
this.etat = 1;
}
if (e.getActionCommand()=="Red") {
this.setBackground(Color.RED);
this.etat = 2;
}
if (e.getActionCommand()=="Green") {
this.setBackground(Color.GREEN);
this.etat = 3;
}
}
}