Soy gay, pero como está escrito en español nadie lo entenderá

This commit is contained in:
Vieira Enzo 2022-04-04 15:20:54 +02:00
parent bb4a78089a
commit 055df406da
4 changed files with 76 additions and 0 deletions

Binary file not shown.

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

Binary file not shown.

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