APL/APL2.1/TP8/Radio/ObservateurRadio.java

35 lines
673 B
Java
Raw Normal View History

import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class ObservateurRadio implements ActionListener
{
private JPanel panneau;
public ObservateurRadio(JPanel panneau)
{
this.panneau = panneau;
}
@Override
public void actionPerformed(ActionEvent e)
{
String action = e.getActionCommand();
if (action == "CYAN")
{
panneau.setBackground(Color.CYAN);
}
else if (action == "MAGENTA")
{
panneau.setBackground(Color.MAGENTA);
}
else if (action == "YELLOW")
{
panneau.setBackground(Color.YELLOW);
}
}
}