2025-03-05 12:29:30 +01:00
|
|
|
import java.awt.*;
|
2025-03-05 20:46:39 +01:00
|
|
|
import java.awt.event.*;
|
2025-03-05 12:29:30 +01:00
|
|
|
import javax.swing.*;
|
|
|
|
|
2025-03-05 20:44:11 +01:00
|
|
|
public class Fond extends JPanel implements ActionListener {
|
2025-03-05 20:46:39 +01:00
|
|
|
private JButton Cyan, Magenta, Jaune;
|
|
|
|
|
|
|
|
public Fond() {
|
2025-03-05 21:32:35 +01:00
|
|
|
super();
|
2025-03-05 20:46:39 +01:00
|
|
|
this.setLayout(null);
|
2025-03-05 20:44:11 +01:00
|
|
|
|
2025-03-05 20:46:39 +01:00
|
|
|
this.Cyan = new JButton("Cyan");
|
|
|
|
this.Magenta = new JButton("Magenta");
|
|
|
|
this.Jaune = new JButton("Jaune");
|
2025-03-05 12:29:30 +01:00
|
|
|
|
2025-03-05 20:46:39 +01:00
|
|
|
this.Cyan.setBounds(100, 50, 100, 30);
|
|
|
|
this.Magenta.setBounds(220, 50, 100, 30);
|
|
|
|
this.Jaune.setBounds(340, 50, 100, 30);
|
2025-03-05 20:38:02 +01:00
|
|
|
|
2025-03-05 20:46:39 +01:00
|
|
|
this.Cyan.addActionListener(this);
|
|
|
|
this.Magenta.addActionListener(this);
|
|
|
|
this.Jaune.addActionListener(this);
|
|
|
|
|
|
|
|
this.add(this.Cyan);
|
|
|
|
this.add(this.Magenta);
|
|
|
|
this.add(this.Jaune);
|
|
|
|
}
|
2025-03-05 20:38:02 +01:00
|
|
|
|
2025-03-05 20:46:39 +01:00
|
|
|
@Override
|
2025-03-05 21:47:00 +01:00
|
|
|
public void actionPerformed(ActionEvent evenement) {
|
2025-03-05 20:46:39 +01:00
|
|
|
if (evenement.getSource() == this.Cyan) {
|
|
|
|
this.setBackground(Color.CYAN);
|
|
|
|
} else if (evenement.getSource() == this.Magenta) {
|
|
|
|
this.setBackground(Color.MAGENTA);
|
|
|
|
} else if (evenement.getSource() == this.Jaune) {
|
|
|
|
this.setBackground(Color.YELLOW);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|