24 lines
598 B
Java
24 lines
598 B
Java
|
import java.awt.Color;
|
||
|
import java.awt.event.*;
|
||
|
import javax.swing.JPanel;
|
||
|
import javax.swing.JButton;
|
||
|
|
||
|
class Observer implements ActionListener {
|
||
|
public Observer() {
|
||
|
|
||
|
}
|
||
|
|
||
|
public void actionPerformed(ActionEvent evt) {
|
||
|
String name = evt.getActionCommand();
|
||
|
JPanel f = (JPanel)((JButton)evt.getSource()).getParent();
|
||
|
|
||
|
|
||
|
if (name == "Jaune") {
|
||
|
f.setBackground(Color.YELLOW);
|
||
|
} else if (name == "Cyan") {
|
||
|
f.setBackground(Color.CYAN);
|
||
|
} else if (name == "Magenta") {
|
||
|
f.setBackground(Color.MAGENTA);
|
||
|
}
|
||
|
}
|
||
|
}
|