flut d'octet
This commit is contained in:
44
DEV2.1/Flux_octet/Memoire/Fond.java
Normal file
44
DEV2.1/Flux_octet/Memoire/Fond.java
Normal 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;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user