This commit is contained in:
Emmanuel Srivastava
2025-03-05 21:36:58 +01:00
parent 3d1afc128c
commit 70336db647
5 changed files with 165 additions and 0 deletions

Binary file not shown.

View File

@@ -0,0 +1,17 @@
import javax.swing.*;
import java.awt.*;
public class MainRadio {
public static void main(String[] args) {
JFrame frame = new JFrame("Radio");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
Radio panel = new Radio();
frame.add(panel);
frame.setSize(500,500);
frame.setLocation(500,250);
frame.setVisible(true);
}
}

View File

@@ -0,0 +1,39 @@
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class Radio extends JPanel implements ActionListener {
private JRadioButton Cyan, Magenta, Jaune;
public Radio() {
super();
this.setLayout(null);
this.Cyan = new JButton("Cyan");
this.Magenta = new JButton("Magenta");
this.Jaune = new JButton("Jaune");
this.Cyan.setBounds(100, 50, 100, 30);
this.Magenta.setBounds(220, 50, 100, 30);
this.Jaune.setBounds(340, 50, 100, 30);
this.Cyan.addActionListener(this);
this.Magenta.addActionListener(this);
this.Jaune.addActionListener(this);
this.add(this.Cyan);
this.add(this.Magenta);
this.add(this.Jaune);
}
@Override
protected void actionPerformed(ActionEvent evenement) {
if (evenement.getSource() == this.Cyan) {
this.setBackground(Color.CYAN);
} else if (evenement.getSource() == this.Magenta) {
this.setBackground(Color.MAGENTA);
} else if (evenement.getSource() == this.Jaune) {
this.setBackground(Color.YELLOW);
}
}
}