Soy gay, pero como está escrito en español nadie lo entenderá
This commit is contained in:
parent
bb4a78089a
commit
055df406da
BIN
APL2.1/TP8/Radio/ObservateurRadio.class
Normal file
BIN
APL2.1/TP8/Radio/ObservateurRadio.class
Normal file
Binary file not shown.
34
APL2.1/TP8/Radio/ObservateurRadio.java
Normal file
34
APL2.1/TP8/Radio/ObservateurRadio.java
Normal file
@ -0,0 +1,34 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
BIN
APL2.1/TP8/Radio/Radio.class
Normal file
BIN
APL2.1/TP8/Radio/Radio.class
Normal file
Binary file not shown.
42
APL2.1/TP8/Radio/Radio.java
Normal file
42
APL2.1/TP8/Radio/Radio.java
Normal file
@ -0,0 +1,42 @@
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class Radio
|
||||
{
|
||||
static public void main(String[] args)
|
||||
{
|
||||
JFrame fenetre = new JFrame();
|
||||
fenetre.setSize(300, 300);
|
||||
fenetre.setLocation(100, 100);
|
||||
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
JPanel panneau = new JPanel();
|
||||
JPanel colorPanel = new JPanel();
|
||||
ButtonGroup groupe = new ButtonGroup();
|
||||
JRadioButton cyanBtn = new JRadioButton("CYAN");
|
||||
JRadioButton magentaBtn = new JRadioButton("MAGENTA");
|
||||
JRadioButton yellowBtn = new JRadioButton("YELLOW");
|
||||
|
||||
ObservateurRadio observateur = new ObservateurRadio(colorPanel);
|
||||
|
||||
panneau.setLayout(new GridLayout(3, 1));
|
||||
|
||||
panneau.add(cyanBtn);
|
||||
panneau.add(magentaBtn);
|
||||
panneau.add(yellowBtn);
|
||||
|
||||
groupe.add(cyanBtn);
|
||||
groupe.add(magentaBtn);
|
||||
groupe.add(yellowBtn);
|
||||
|
||||
cyanBtn.addActionListener(observateur);
|
||||
magentaBtn.addActionListener(observateur);
|
||||
yellowBtn.addActionListener(observateur);
|
||||
|
||||
fenetre.add(colorPanel);
|
||||
fenetre.add(panneau, BorderLayout.SOUTH);
|
||||
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user