diff --git a/DEV2.1/TP7:Evenements/Attente.class b/DEV2.1/TP7:Evenements/Attente.class new file mode 100644 index 0000000..2eece50 Binary files /dev/null and b/DEV2.1/TP7:Evenements/Attente.class differ diff --git a/DEV2.1/TP7:Evenements/Attente.java b/DEV2.1/TP7:Evenements/Attente.java new file mode 100644 index 0000000..9ea5b52 --- /dev/null +++ b/DEV2.1/TP7:Evenements/Attente.java @@ -0,0 +1,61 @@ +import java.awt.*; +import javax.swing.*; +import java.awt.event.*; + +public class Attente extends JPanel implements WindowListener{ + + boolean plan = false; + + public Attente() { + super(); + } + + protected void paintComponent(Graphics pinceau) { + // obligatoire : on cree un nouveau pinceau pour pouvoir le modifier plus tard + Graphics pinceau2 = pinceau.create(); + if (this.isOpaque()) { + // obligatoire : on repeint toute la surface avec la couleur de fond + pinceau2.setColor(Color.GREEN); + pinceau2.fillRect(0, 0, this.getWidth(), this.getHeight()); + } if (this.plan==true){ + pinceau2.setColor(Color.GREEN); + pinceau2.fillRect(0, 0, this.getWidth(), this.getHeight()); + pinceau2.setColor(Color.MAGENTA); + pinceau2.fillOval(0, 0, this.getWidth(), this.getHeight()); + } else{ + pinceau2.setColor(Color.GREEN); + pinceau2.fillRect(0, 0, this.getWidth(), this.getHeight()); + pinceau2.setColor(Color.MAGENTA); + int[] x={0,this.getWidth()/2,this.getWidth(),this.getWidth()/2}; + int[] y={this.getHeight()/2,0,this.getHeight()/2,this.getHeight()}; + pinceau2.drawPolygon(x,y,x.length); + pinceau2.fillPolygon(x,y,x.length); + } +} + + public void windowDeactivated(WindowEvent evenement){ + this.plan=false; + this.repaint(); + } + + public void windowActivated(WindowEvent evenement){ + this.plan=true; + this.repaint(); + + } + + public void windowClosed(WindowEvent evenement){ + } + + public void windowClosing(WindowEvent evenement){ + } + + public void windowDeiconified(WindowEvent evenement){ + } + + public void windowIconified(WindowEvent evenement){ + } + + public void windowOpened(WindowEvent evenement){ + } +} \ No newline at end of file diff --git a/DEV2.1/TP7:Evenements/Fond.class b/DEV2.1/TP7:Evenements/Fond.class new file mode 100644 index 0000000..6a621ca Binary files /dev/null and b/DEV2.1/TP7:Evenements/Fond.class differ diff --git a/DEV2.1/TP7:Evenements/Fond.java b/DEV2.1/TP7:Evenements/Fond.java new file mode 100644 index 0000000..fbb852b --- /dev/null +++ b/DEV2.1/TP7:Evenements/Fond.java @@ -0,0 +1,36 @@ +import java.awt.*; +import javax.swing.*; +import java.awt.event.*; + +public class Fond extends JPanel implements ActionListener{ + + public Fond() { + super(); + JButton magenta = new JButton("magenta"); + JButton cyan = new JButton("cyan"); + JButton jaune = new JButton("jaune"); + this.add(magenta); + this.add(cyan); + this.add(jaune); + magenta.addActionListener(this); + cyan.addActionListener(this); + jaune.addActionListener(this); + + } + + public void actionPerformed(ActionEvent evenement){ + String commande = new String(); + commande="cyan"; + if(true==commande.equals(evenement.getActionCommand())){ + this.setBackground(Color.CYAN); + } + commande="magenta"; + if(true==commande.equals(evenement.getActionCommand())){ + this.setBackground(Color.MAGENTA); + } + commande="jaune"; + if(true==commande.equals(evenement.getActionCommand())){ + this.setBackground(Color.YELLOW); + } + } +} \ No newline at end of file diff --git a/DEV2.1/TP7:Evenements/Mainattente.class b/DEV2.1/TP7:Evenements/Mainattente.class new file mode 100644 index 0000000..2971254 Binary files /dev/null and b/DEV2.1/TP7:Evenements/Mainattente.class differ diff --git a/DEV2.1/TP7:Evenements/Mainattente.java b/DEV2.1/TP7:Evenements/Mainattente.java new file mode 100644 index 0000000..d0c720f --- /dev/null +++ b/DEV2.1/TP7:Evenements/Mainattente.java @@ -0,0 +1,17 @@ +import java.awt.*; +import javax.swing.*; + +public class Mainattente{ + + public static void main(String[] args) { + + JFrame fenetre = new JFrame(); + Attente pan = new Attente(); + fenetre.setSize(500, 500); + fenetre.setLocation(0, 0); + fenetre.addWindowListener(pan); + fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + fenetre.setContentPane(pan); + fenetre.setVisible(true); + } +} \ No newline at end of file diff --git a/DEV2.1/TP7:Evenements/Mainfond.class b/DEV2.1/TP7:Evenements/Mainfond.class new file mode 100644 index 0000000..a486c2f Binary files /dev/null and b/DEV2.1/TP7:Evenements/Mainfond.class differ diff --git a/DEV2.1/TP7:Evenements/Mainfond.java b/DEV2.1/TP7:Evenements/Mainfond.java new file mode 100644 index 0000000..5ace4c5 --- /dev/null +++ b/DEV2.1/TP7:Evenements/Mainfond.java @@ -0,0 +1,16 @@ +import java.awt.*; +import javax.swing.*; + +public class Mainfond{ + + public static void main(String[] args) { + + JFrame fenetre = new JFrame(); + Fond pan = new Fond(); + fenetre.setSize(500, 500); + fenetre.setLocation(0, 0); + fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + fenetre.setContentPane(pan); + fenetre.setVisible(true); + } +} \ No newline at end of file