30 lines
782 B
Java
30 lines
782 B
Java
|
import javax.swing.*;
|
||
|
import java.awt.*;
|
||
|
import java.awt.event.*;
|
||
|
|
||
|
public class Fond extends JPanel implements ActionListener
|
||
|
{
|
||
|
public Fond(){
|
||
|
super();
|
||
|
JButton cyan = new JButton("Cyan");
|
||
|
JButton magenta = new JButton("Magenta");
|
||
|
JButton jaune = new JButton("Jaune");
|
||
|
this.add(cyan);
|
||
|
this.add(magenta);
|
||
|
this.add(jaune);
|
||
|
cyan.addActionListener(this);
|
||
|
magenta.addActionListener(this);
|
||
|
jaune.addActionListener(this);
|
||
|
}
|
||
|
public void actionPerformed(ActionEvent evenement){
|
||
|
String test;
|
||
|
test = evenement.getActionCommand();
|
||
|
if(test.equals("Cyan")){
|
||
|
this.setBackground(Color.CYAN);
|
||
|
}if(test.equals("Magenta")){
|
||
|
this.setBackground(Color.MAGENTA);
|
||
|
}if(test.equals("Jaune")){
|
||
|
this.setBackground(Color.YELLOW);
|
||
|
}
|
||
|
}
|
||
|
}
|