update
This commit is contained in:
0
DEV/DEV2.1/TP08_Evenement/ActionListener.java~
Normal file
0
DEV/DEV2.1/TP08_Evenement/ActionListener.java~
Normal file
0
DEV/DEV2.1/TP08_Evenement/Fond.java~
Normal file
0
DEV/DEV2.1/TP08_Evenement/Fond.java~
Normal file
28
DEV/DEV2.1/TP08_Evenement/FondEvent.java~
Normal file
28
DEV/DEV2.1/TP08_Evenement/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);
|
||||
}
|
||||
@Overrides
|
||||
void actionPerformed(ActionEvent evenement){
|
||||
String couleur = this.getActionCommand();
|
||||
boutonContainer.setBackground(couleur);
|
||||
}
|
||||
}
|
||||
0
DEV/DEV2.1/TP08_Evenement/Fond_event.java~
Normal file
0
DEV/DEV2.1/TP08_Evenement/Fond_event.java~
Normal file
18
DEV/DEV2.1/TP08_Evenement/Q1_Fond/Fond.java~
Normal file
18
DEV/DEV2.1/TP08_Evenement/Q1_Fond/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/Q1_Fond/FondEvent.class
Normal file
BIN
DEV/DEV2.1/TP08_Evenement/Q1_Fond/FondEvent.class
Normal file
Binary file not shown.
25
DEV/DEV2.1/TP08_Evenement/Q1_Fond/FondEvent.java
Normal file
25
DEV/DEV2.1/TP08_Evenement/Q1_Fond/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/Q1_Fond/FondEvent.java~
Normal file
28
DEV/DEV2.1/TP08_Evenement/Q1_Fond/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);
|
||||
}
|
||||
}
|
||||
BIN
DEV/DEV2.1/TP08_Evenement/Q1_Fond/Q1Main.class
Normal file
BIN
DEV/DEV2.1/TP08_Evenement/Q1_Fond/Q1Main.class
Normal file
Binary file not shown.
30
DEV/DEV2.1/TP08_Evenement/Q1_Fond/Q1Main.java
Normal file
30
DEV/DEV2.1/TP08_Evenement/Q1_Fond/Q1Main.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);
|
||||
}
|
||||
}
|
||||
31
DEV/DEV2.1/TP08_Evenement/Q1_Fond/Q1Main.java~
Normal file
31
DEV/DEV2.1/TP08_Evenement/Q1_Fond/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/Q2_Attente/Evenement.class
Normal file
BIN
DEV/DEV2.1/TP08_Evenement/Q2_Attente/Evenement.class
Normal file
Binary file not shown.
45
DEV/DEV2.1/TP08_Evenement/Q2_Attente/Evenement.java
Normal file
45
DEV/DEV2.1/TP08_Evenement/Q2_Attente/Evenement.java
Normal file
@@ -0,0 +1,45 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class Evenement extends JComponent implements WindowListener{
|
||||
public int etat;
|
||||
|
||||
public Evenement(){
|
||||
this.etat = 1;
|
||||
}
|
||||
@Override
|
||||
protected void paintComponent(Graphics pinceau) {
|
||||
Graphics secondPinceau = pinceau.create();
|
||||
int longueur = this.getWidth();
|
||||
int hauteur = this.getHeight();
|
||||
secondPinceau.setColor(Color.GREEN);
|
||||
secondPinceau.fillRect(0, 0, longueur, hauteur);
|
||||
secondPinceau.setColor(Color.MAGENTA);
|
||||
if (this.etat==1){
|
||||
secondPinceau.fillOval(0,0,longueur,hauteur);
|
||||
}
|
||||
if (this.etat==2){
|
||||
int[] triangleXHaut = {0, longueur, longueur/2};
|
||||
int[] triangleYHaut = {0, 0, hauteur/2};
|
||||
int[] triangleXBas = {0, longueur, longueur/2};
|
||||
int[] triangleYBas = {hauteur, hauteur, hauteur/2};
|
||||
secondPinceau.fillPolygon(triangleXHaut, triangleYHaut, 3);
|
||||
secondPinceau.fillPolygon(triangleXBas, triangleYBas, 3);
|
||||
}
|
||||
}
|
||||
|
||||
public void windowActivated(WindowEvent evenement){
|
||||
this.etat=1;
|
||||
repaint();
|
||||
}
|
||||
public void windowClosed(WindowEvent evenement){}
|
||||
public void windowClosing(WindowEvent evenement){}
|
||||
public void windowDeactivated(WindowEvent evenement){
|
||||
this.etat=2;
|
||||
repaint();
|
||||
}
|
||||
public void windowDeiconified(WindowEvent evenement){}
|
||||
public void windowIconified(WindowEvent evenement){}
|
||||
public void windowOpened(WindowEvent evenement){}
|
||||
}
|
||||
39
DEV/DEV2.1/TP08_Evenement/Q2_Attente/Evenement.java~
Normal file
39
DEV/DEV2.1/TP08_Evenement/Q2_Attente/Evenement.java~
Normal file
@@ -0,0 +1,39 @@
|
||||
public class Evenement implements WindowListener extends JComponent{
|
||||
public int etat;
|
||||
|
||||
public Evenement(){
|
||||
this.etat = 1;
|
||||
}
|
||||
@Override
|
||||
protected void paintComponent(Graphics pinceau) {
|
||||
Graphics secondPinceau = pinceau.create();
|
||||
int longueur = this.getWidth();
|
||||
int hauteur = this.getHeight();
|
||||
secondPinceau.setColor(Color.GREEN);
|
||||
secondPinceau.fillRect(0, 0, longueur, hauteur);
|
||||
secondPinceau.setColor(Color.MAGENTA);
|
||||
if (this.etat==1){
|
||||
secondPinceau.fillOval(0,0,longueur,hauteur);
|
||||
}
|
||||
if (this.etat==2){
|
||||
int[] triangleXHaut = {0, longueur, longueur/2};
|
||||
int[] triangleYHaut = {0, 0, hauteur/2};
|
||||
int[] triangleXBas = {0, longueur, longueur/2};
|
||||
int[] triangleYBas = {hauteur, hauteur, hauteur/2};
|
||||
secondPinceau.fillPolygon(triangleXHaut, triangleYHaut, 3);
|
||||
secondPinceau.fillPolygon(triangleXBas, triangleYBas, 3);
|
||||
}
|
||||
}
|
||||
|
||||
public void windowActivated(WindowEvent evenement){
|
||||
this.etat=1;
|
||||
}
|
||||
public void windowClosed(WindowEvent evenement){}
|
||||
public void windowClosing(WindowEvent evenement){}
|
||||
public void windowDeactivated(WindowEvent evenement){
|
||||
this.etat=2;
|
||||
}
|
||||
public void windowDeiconified(WindowEvent evenement){}
|
||||
public void windowIconified(WindowEvent evenement){}
|
||||
public void windowOpened(WindowEvent evenement){}
|
||||
}
|
||||
BIN
DEV/DEV2.1/TP08_Evenement/Q2_Attente/Q2Main.class
Normal file
BIN
DEV/DEV2.1/TP08_Evenement/Q2_Attente/Q2Main.class
Normal file
Binary file not shown.
18
DEV/DEV2.1/TP08_Evenement/Q2_Attente/Q2Main.java
Normal file
18
DEV/DEV2.1/TP08_Evenement/Q2_Attente/Q2Main.java
Normal file
@@ -0,0 +1,18 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class Q2Main{
|
||||
public static void main(String[] args) {
|
||||
JFrame fenetre = new JFrame();
|
||||
fenetre.setSize(500, 300);
|
||||
fenetre.setLocation(0, 0);
|
||||
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
Evenement forme = new Evenement();
|
||||
fenetre.add(forme);
|
||||
fenetre.addWindowListener(forme);
|
||||
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
}
|
||||
0
DEV/DEV2.1/TP08_Evenement/Q2_Attente/Q2Main.java~
Normal file
0
DEV/DEV2.1/TP08_Evenement/Q2_Attente/Q2Main.java~
Normal file
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);
|
||||
}
|
||||
}
|
||||
18
DEV/DEV2.1/TP08_Evenement/Q4_Combinaison/Fond.java~
Normal file
18
DEV/DEV2.1/TP08_Evenement/Q4_Combinaison/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/Q4_Combinaison/FondEvent.class
Normal file
BIN
DEV/DEV2.1/TP08_Evenement/Q4_Combinaison/FondEvent.class
Normal file
Binary file not shown.
45
DEV/DEV2.1/TP08_Evenement/Q4_Combinaison/FondEvent.java
Normal file
45
DEV/DEV2.1/TP08_Evenement/Q4_Combinaison/FondEvent.java
Normal file
@@ -0,0 +1,45 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class FondEvent implements ActionListener{
|
||||
public JPanel panneau;
|
||||
public JCheckBox boutonCyan;
|
||||
public JCheckBox boutonMagenta;
|
||||
public JCheckBox boutonJaune;
|
||||
public static Color[] listeCouleur= {
|
||||
Color.WHITE,
|
||||
Color.YELLOW,
|
||||
Color.MAGENTA,
|
||||
Color.RED,
|
||||
Color.CYAN,
|
||||
Color.GREEN,
|
||||
Color.BLUE,
|
||||
Color.BLACK
|
||||
};
|
||||
|
||||
public FondEvent(JPanel contenu){
|
||||
this.panneau = contenu;
|
||||
this.boutonCyan = new JCheckBox("Cyan");
|
||||
this.boutonMagenta = new JCheckBox("Magenta");
|
||||
this.boutonJaune = new JCheckBox("Jaune");
|
||||
this.panneau.add(this.boutonCyan);
|
||||
this.panneau.add(this.boutonMagenta);
|
||||
this.panneau.add(this.boutonJaune);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent evenement){
|
||||
int numCouleur = 0;
|
||||
if (this.boutonCyan.isSelected()){
|
||||
numCouleur += 4;
|
||||
}
|
||||
if (this.boutonMagenta.isSelected()){
|
||||
numCouleur += 2;
|
||||
}
|
||||
if (this.boutonJaune.isSelected()){
|
||||
numCouleur += 1;
|
||||
}
|
||||
panneau.setBackground(FondEvent.listeCouleur[numCouleur]);
|
||||
}
|
||||
}
|
||||
25
DEV/DEV2.1/TP08_Evenement/Q4_Combinaison/FondEvent.java~
Normal file
25
DEV/DEV2.1/TP08_Evenement/Q4_Combinaison/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);
|
||||
}
|
||||
}
|
||||
}
|
||||
30
DEV/DEV2.1/TP08_Evenement/Q4_Combinaison/Q1Main.java~
Normal file
30
DEV/DEV2.1/TP08_Evenement/Q4_Combinaison/Q1Main.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);
|
||||
}
|
||||
}
|
||||
BIN
DEV/DEV2.1/TP08_Evenement/Q4_Combinaison/Q4Main.class
Normal file
BIN
DEV/DEV2.1/TP08_Evenement/Q4_Combinaison/Q4Main.class
Normal file
Binary file not shown.
23
DEV/DEV2.1/TP08_Evenement/Q4_Combinaison/Q4Main.java
Normal file
23
DEV/DEV2.1/TP08_Evenement/Q4_Combinaison/Q4Main.java
Normal file
@@ -0,0 +1,23 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class Q4Main{
|
||||
public static void main(String[] args) {
|
||||
JFrame fenetre = new JFrame();
|
||||
fenetre.setSize(500, 300);
|
||||
fenetre.setLocation(0, 0);
|
||||
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
JPanel contenu = new JPanel();
|
||||
|
||||
FondEvent evenementBouton = new FondEvent(contenu);
|
||||
|
||||
evenementBouton.boutonCyan.addActionListener(evenementBouton);
|
||||
evenementBouton.boutonMagenta.addActionListener(evenementBouton);
|
||||
evenementBouton.boutonJaune.addActionListener(evenementBouton);
|
||||
|
||||
fenetre.add(contenu);
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
}
|
||||
30
DEV/DEV2.1/TP08_Evenement/Q4_Combinaison/Q4Main.java~
Normal file
30
DEV/DEV2.1/TP08_Evenement/Q4_Combinaison/Q4Main.java~
Normal file
@@ -0,0 +1,30 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class Q4Main{
|
||||
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);
|
||||
}
|
||||
}
|
||||
18
DEV/DEV2.1/TP08_Evenement/Q5_Commande/Fond.java~
Normal file
18
DEV/DEV2.1/TP08_Evenement/Q5_Commande/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/Q5_Commande/FondEvent.class
Normal file
BIN
DEV/DEV2.1/TP08_Evenement/Q5_Commande/FondEvent.class
Normal file
Binary file not shown.
30
DEV/DEV2.1/TP08_Evenement/Q5_Commande/FondEvent.java
Normal file
30
DEV/DEV2.1/TP08_Evenement/Q5_Commande/FondEvent.java
Normal file
@@ -0,0 +1,30 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class FondEvent implements ActionListener{
|
||||
public JPanel panneau;
|
||||
public JTextField champsSaisis;
|
||||
|
||||
public FondEvent(JPanel contenu){
|
||||
this.champsSaisis = new JTextField();
|
||||
this.champsSaisis.setPreferredSize(new Dimension(200,20));
|
||||
this.panneau = contenu;
|
||||
this.panneau.add(this.champsSaisis);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent evenement){
|
||||
String couleur = evenement.getActionCommand();
|
||||
if (couleur.equals("Cyan")){
|
||||
panneau.setBackground(Color.CYAN);
|
||||
}
|
||||
if (couleur.equals("Magenta")){
|
||||
panneau.setBackground(Color.MAGENTA);
|
||||
}
|
||||
if (couleur.equals("Jaune")){
|
||||
panneau.setBackground(Color.YELLOW);
|
||||
}
|
||||
this.champsSaisis.setText("");
|
||||
}
|
||||
}
|
||||
25
DEV/DEV2.1/TP08_Evenement/Q5_Commande/FondEvent.java~
Normal file
25
DEV/DEV2.1/TP08_Evenement/Q5_Commande/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);
|
||||
}
|
||||
}
|
||||
}
|
||||
30
DEV/DEV2.1/TP08_Evenement/Q5_Commande/Q1Main.java~
Normal file
30
DEV/DEV2.1/TP08_Evenement/Q5_Commande/Q1Main.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);
|
||||
}
|
||||
}
|
||||
BIN
DEV/DEV2.1/TP08_Evenement/Q5_Commande/Q5Main.class
Normal file
BIN
DEV/DEV2.1/TP08_Evenement/Q5_Commande/Q5Main.class
Normal file
Binary file not shown.
20
DEV/DEV2.1/TP08_Evenement/Q5_Commande/Q5Main.java
Normal file
20
DEV/DEV2.1/TP08_Evenement/Q5_Commande/Q5Main.java
Normal file
@@ -0,0 +1,20 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class Q5Main{
|
||||
public static void main(String[] args) {
|
||||
JFrame fenetre = new JFrame();
|
||||
fenetre.setSize(500, 300);
|
||||
fenetre.setLocation(0, 0);
|
||||
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
JPanel contenu = new JPanel();
|
||||
FondEvent evenementBouton = new FondEvent(contenu);
|
||||
|
||||
evenementBouton.champsSaisis.addActionListener(evenementBouton);
|
||||
|
||||
fenetre.add(contenu);
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
}
|
||||
24
DEV/DEV2.1/TP08_Evenement/Q5_Commande/Q5Main.java~
Normal file
24
DEV/DEV2.1/TP08_Evenement/Q5_Commande/Q5Main.java~
Normal file
@@ -0,0 +1,24 @@
|
||||
import javax.swing.*;
|
||||
import java.awt.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class Q5Main{
|
||||
public static void main(String[] args) {
|
||||
JFrame fenetre = new JFrame();
|
||||
fenetre.setSize(500, 300);
|
||||
fenetre.setLocation(0, 0);
|
||||
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
|
||||
JTextField champsSaisis = new JTextField();
|
||||
|
||||
JPanel contenu = new JPanel();
|
||||
contenu.add(champsSaisis);
|
||||
|
||||
FondEvent evenementBouton = new FondEvent(contenu);
|
||||
|
||||
champsSaisis.addActionListener(evenementBouton);
|
||||
|
||||
fenetre.add(contenu);
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user