APL/APL2.1/TP14/Memoire/Observer.java
2022-05-23 16:20:43 +02:00

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);
}
}
}