flut d'octet

This commit is contained in:
2024-03-25 14:56:28 +01:00
parent 0bf4ebd6b6
commit f411998b31
30 changed files with 335 additions and 3 deletions

View File

@@ -0,0 +1,44 @@
import javax.swing.*;
import java.awt.*;
import java.util.*;
import java.awt.event.*;
public class Fond extends JPanel implements ActionListener{
public Fond(){
super();
// Création des boutons
JButton cyanButton = new JButton("Cyan");
JButton magentaButton = new JButton("Magenta");
JButton yellowButton = new JButton("Jaune");
// Ajout des action listeners aux boutons
cyanButton.addActionListener(this);
magentaButton.addActionListener(this);
yellowButton.addActionListener(this);
// Création du panneau pour contrôler la couleur de fond
this.add(cyanButton);
this.add(magentaButton);
this.add(yellowButton);
}
@Override
public void actionPerformed(ActionEvent e) {
String command = e.getActionCommand();
switch (command) {
case "Cyan":
this.setBackground(Color.CYAN);
break;
case "Magenta":
this.setBackground(Color.MAGENTA);
break;
case "Jaune":
this.setBackground(Color.YELLOW);
break;
default:
break;
}
}
}