2025-03-05 12:29:30 +01:00
|
|
|
import java.awt.*;
|
|
|
|
import javax.swing.*;
|
|
|
|
|
|
|
|
public class Fond {
|
|
|
|
private JButton Cyan, Magenta, Jaune;
|
|
|
|
|
|
|
|
public Fond() {
|
2025-03-05 20:38:02 +01:00
|
|
|
this.setLayout(null);
|
2025-03-05 12:29:30 +01:00
|
|
|
this.Cyan = new JButton("Cyan");
|
|
|
|
this.Magenta = new JButton("Magenta");
|
|
|
|
this.Jaune = new JButton("Jaune");
|
|
|
|
|
|
|
|
this.Cyan.setBounds(100,50,100,20);
|
|
|
|
this.Magenta.setBounds(220,50,100,20);
|
|
|
|
this.Jaune.setBounds(320,50,100,20);
|
2025-03-05 20:38:02 +01:00
|
|
|
|
|
|
|
this.Cyan.addActionListener(this);
|
|
|
|
this.Magenta.addActionListener(this);
|
|
|
|
this.Jaune.addActionListener(this);
|
|
|
|
|
|
|
|
frame.add(this.Cyan);
|
|
|
|
frame.add(this.Magenta);
|
|
|
|
frame.add(this.Jaune);
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
|
|
public void actionPerformed(ActionEvent evenement) {
|
|
|
|
if (evenement.getSource() == this.Cyan) {
|
|
|
|
frame.setBackground(Color.CYAN);
|
|
|
|
} else if (evenement.getSource() == this.Magenta) {
|
|
|
|
frame.setBackground(Color.MAGENTA);
|
|
|
|
} else if (evenement.getSource() == this.Jaune) {
|
|
|
|
frame.setBackground(Color.JAUNE);
|
|
|
|
}
|
2025-03-05 12:29:30 +01:00
|
|
|
}
|
|
|
|
}
|