update
This commit is contained in:
18
DEV/DEV2.1/TP08_Evenement/Q3_Radio/Fond.java~
Normal file
18
DEV/DEV2.1/TP08_Evenement/Q3_Radio/Fond.java~
Normal file
@@ -0,0 +1,18 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class Fond{
|
||||
public static void main(String[] args) {
|
||||
JButton boutonCyan = new JButton("Cyan");
|
||||
JButton boutonMagenta = new JButton("Magenta");
|
||||
JButton boutonJaune = new JButton("Jaune");
|
||||
JButton[] boutonList = {boutonCyan,boutonMagenta,boutonJaune};
|
||||
FondEvent fenetreClass = new FondEvent(boutonList);
|
||||
|
||||
fenetreClass.fenetre();
|
||||
|
||||
boutonCyan.addActionListener(fenetreClass);
|
||||
boutonMagenta.addActionListener(fenetreClass);
|
||||
boutonJaune.addActionListener(fenetreClass);
|
||||
}
|
||||
}
|
||||
BIN
DEV/DEV2.1/TP08_Evenement/Q3_Radio/FondEvent.class
Normal file
BIN
DEV/DEV2.1/TP08_Evenement/Q3_Radio/FondEvent.class
Normal file
Binary file not shown.
25
DEV/DEV2.1/TP08_Evenement/Q3_Radio/FondEvent.java
Normal file
25
DEV/DEV2.1/TP08_Evenement/Q3_Radio/FondEvent.java
Normal file
@@ -0,0 +1,25 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class FondEvent implements ActionListener{
|
||||
public JPanel panneau;
|
||||
|
||||
public FondEvent(JPanel contenu){
|
||||
this.panneau = contenu;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent evenement){
|
||||
String couleur = evenement.getActionCommand();
|
||||
if (couleur=="Cyan"){
|
||||
panneau.setBackground(Color.CYAN);
|
||||
}
|
||||
if (couleur=="Magenta"){
|
||||
panneau.setBackground(Color.MAGENTA);
|
||||
}
|
||||
if (couleur=="Jaune"){
|
||||
panneau.setBackground(Color.YELLOW);
|
||||
}
|
||||
}
|
||||
}
|
||||
28
DEV/DEV2.1/TP08_Evenement/Q3_Radio/FondEvent.java~
Normal file
28
DEV/DEV2.1/TP08_Evenement/Q3_Radio/FondEvent.java~
Normal file
@@ -0,0 +1,28 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class FondEvent implements ActionListener{
|
||||
public JPanel panneau;
|
||||
|
||||
public FondEvent(JButton[] boutons){
|
||||
panneau = new JPanel();
|
||||
for (JButton bouton : boutons){
|
||||
panneau.add(bouton);
|
||||
}
|
||||
boutonContainer.setBackground(new Color(46,209,111));
|
||||
}
|
||||
|
||||
public void fenetre(){
|
||||
JFrame fenetre = new JFrame();
|
||||
fenetre.setSize(500, 300);
|
||||
fenetre.setLocation(0, 0);
|
||||
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
fenetre.add(boutonContainer, BorderLayout.CENTER);
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
@Override
|
||||
void actionPerformed(ActionEvent evenement){
|
||||
String couleur = this.getActionCommand();
|
||||
boutonContainer.setBackground(couleur);
|
||||
}
|
||||
}
|
||||
31
DEV/DEV2.1/TP08_Evenement/Q3_Radio/Q1Main.java~
Normal file
31
DEV/DEV2.1/TP08_Evenement/Q3_Radio/Q1Main.java~
Normal file
@@ -0,0 +1,31 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
|
||||
public class Q1Main{
|
||||
public static void main(String[] args) {
|
||||
Frame fenetre = new JFrame();
|
||||
fenetre.setSize(500, 300);
|
||||
fenetre.setLocation(0, 0);
|
||||
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
JButton boutonCyan = new JButton("Cyan");
|
||||
JButton boutonMagenta = new JButton("Magenta");
|
||||
JButton boutonJaune = new JButton("Jaune");
|
||||
|
||||
JPanel contenu = new JPanel();
|
||||
GridLayout grille = new GridLayout(3,1);
|
||||
contenu.setLayout(grille);
|
||||
contenu.add(boutonCyan);
|
||||
contenu.add(boutonMagenta);
|
||||
contenu.add(boutonJaune);
|
||||
|
||||
FondEvent evenementBouton = new FondEvent(contenu);
|
||||
|
||||
boutonCyan.addActionListener(evenementBouton);
|
||||
boutonMagenta.addActionListener(evenementBouton);
|
||||
boutonJaune.addActionListener(evenementBouton);
|
||||
|
||||
fenetre.add(contenu);
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
}
|
||||
BIN
DEV/DEV2.1/TP08_Evenement/Q3_Radio/Q3Main.class
Normal file
BIN
DEV/DEV2.1/TP08_Evenement/Q3_Radio/Q3Main.class
Normal file
Binary file not shown.
35
DEV/DEV2.1/TP08_Evenement/Q3_Radio/Q3Main.java
Normal file
35
DEV/DEV2.1/TP08_Evenement/Q3_Radio/Q3Main.java
Normal file
@@ -0,0 +1,35 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class Q3Main{
|
||||
public static void main(String[] args) {
|
||||
JFrame fenetre = new JFrame();
|
||||
fenetre.setSize(500, 300);
|
||||
fenetre.setLocation(0, 0);
|
||||
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
JRadioButton boutonCyan = new JRadioButton("Cyan");
|
||||
JRadioButton boutonMagenta = new JRadioButton("Magenta");
|
||||
JRadioButton boutonJaune = new JRadioButton("Jaune");
|
||||
|
||||
ButtonGroup groupeBouton = new ButtonGroup();
|
||||
groupeBouton.add(boutonCyan);
|
||||
groupeBouton.add(boutonMagenta);
|
||||
groupeBouton.add(boutonJaune);
|
||||
|
||||
JPanel contenu = new JPanel();
|
||||
contenu.add(boutonCyan);
|
||||
contenu.add(boutonMagenta);
|
||||
contenu.add(boutonJaune);
|
||||
|
||||
FondEvent evenementBouton = new FondEvent(contenu);
|
||||
|
||||
boutonCyan.addActionListener(evenementBouton);
|
||||
boutonMagenta.addActionListener(evenementBouton);
|
||||
boutonJaune.addActionListener(evenementBouton);
|
||||
|
||||
fenetre.add(contenu);
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
}
|
||||
30
DEV/DEV2.1/TP08_Evenement/Q3_Radio/Q3Main.java~
Normal file
30
DEV/DEV2.1/TP08_Evenement/Q3_Radio/Q3Main.java~
Normal file
@@ -0,0 +1,30 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class Q1Main{
|
||||
public static void main(String[] args) {
|
||||
JFrame fenetre = new JFrame();
|
||||
fenetre.setSize(500, 300);
|
||||
fenetre.setLocation(0, 0);
|
||||
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
JButton boutonCyan = new JButton("Cyan");
|
||||
JButton boutonMagenta = new JButton("Magenta");
|
||||
JButton boutonJaune = new JButton("Jaune");
|
||||
|
||||
JPanel contenu = new JPanel();
|
||||
contenu.add(boutonCyan);
|
||||
contenu.add(boutonMagenta);
|
||||
contenu.add(boutonJaune);
|
||||
|
||||
FondEvent evenementBouton = new FondEvent(contenu);
|
||||
|
||||
boutonCyan.addActionListener(evenementBouton);
|
||||
boutonMagenta.addActionListener(evenementBouton);
|
||||
boutonJaune.addActionListener(evenementBouton);
|
||||
|
||||
fenetre.add(contenu);
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user