36 lines
894 B
Java
36 lines
894 B
Java
import java.awt.*;
|
|
import javax.swing.*;
|
|
import java.awt.event.*;
|
|
|
|
public class Fond2 extends JPanel implements ActionListener{
|
|
|
|
public Fond2() {
|
|
super();
|
|
JButton magenta = new JButton("magenta");
|
|
JButton cyan = new JButton("cyan");
|
|
JButton jaune = new JButton("jaune");
|
|
this.add(magenta);
|
|
this.add(cyan);
|
|
this.add(jaune);
|
|
magenta.addActionListener(this);
|
|
cyan.addActionListener(this);
|
|
jaune.addActionListener(this);
|
|
|
|
}
|
|
|
|
public void actionPerformed(ActionEvent evenement){
|
|
String commande = new String();
|
|
commande="cyan";
|
|
if(true==commande.equals(evenement.getActionCommand())){
|
|
this.setBackground(Color.CYAN);
|
|
}
|
|
commande="magenta";
|
|
if(true==commande.equals(evenement.getActionCommand())){
|
|
this.setBackground(Color.MAGENTA);
|
|
}
|
|
commande="jaune";
|
|
if(true==commande.equals(evenement.getActionCommand())){
|
|
this.setBackground(Color.YELLOW);
|
|
}
|
|
}
|
|
} |