From bfcbd6473587ee445a9b8edb3d545d4f40d9d464 Mon Sep 17 00:00:00 2001 From: pourchot Date: Fri, 14 Apr 2023 11:29:17 +0200 Subject: [PATCH] 14 Avril --- DEV2.1/TP7:Evenements/Attente.class | Bin 0 -> 1503 bytes DEV2.1/TP7:Evenements/Attente.java | 61 ++++++++++++++++++++++++ DEV2.1/TP7:Evenements/Fond.class | Bin 0 -> 1079 bytes DEV2.1/TP7:Evenements/Fond.java | 36 ++++++++++++++ DEV2.1/TP7:Evenements/Mainattente.class | Bin 0 -> 644 bytes DEV2.1/TP7:Evenements/Mainattente.java | 17 +++++++ DEV2.1/TP7:Evenements/Mainfond.class | Bin 0 -> 559 bytes DEV2.1/TP7:Evenements/Mainfond.java | 16 +++++++ 8 files changed, 130 insertions(+) create mode 100644 DEV2.1/TP7:Evenements/Attente.class create mode 100644 DEV2.1/TP7:Evenements/Attente.java create mode 100644 DEV2.1/TP7:Evenements/Fond.class create mode 100644 DEV2.1/TP7:Evenements/Fond.java create mode 100644 DEV2.1/TP7:Evenements/Mainattente.class create mode 100644 DEV2.1/TP7:Evenements/Mainattente.java create mode 100644 DEV2.1/TP7:Evenements/Mainfond.class create mode 100644 DEV2.1/TP7:Evenements/Mainfond.java diff --git a/DEV2.1/TP7:Evenements/Attente.class b/DEV2.1/TP7:Evenements/Attente.class new file mode 100644 index 0000000000000000000000000000000000000000..2eece50025e21d0719d24d6500f2b042a6504e51 GIT binary patch literal 1503 zcmah}T~iZR7=BK6!zRn}Q7snyLhvgDFjOs8q1YG$#sYD`fuT+>*5nXQU3b%Df%bRw z$~*78wo}uYPKR5a{v{p9=WIg4Feu6FoA={+-aYU0p2`0o|J?&HjU^lXxROL4uG%<* zlud6ei8RJ_IHAKyZLaAsqYG2o`&OIl+T769n-;#aFm2(MfLZliUqJjU&^4=k70wA5 zsj)RyazR-N^erl1E^j}7Dr=A3ryeuCRag08E_hxIeCdY*r&5c*x;t*h-3>DfHMhE@ zO7$7tqGvU9OV5_vYQ(hgy}(zy$}b1I_oZ73)s7p=vcT{GzT9EU%z6aMYd>n#*JNco z9H*Jdc|l#b=;?&YuN-)dDh0mUR2tK2Qs`t_O^Q|NYk<8PY}ZP1Ug;^FY#8$O@|qsa z!PgjYZ~`YC+{PUTGnlpTgM&HTb?_sy4(=i6;J!9_%sW`ng$LRz;Gu(`v{}S}fYs_N za6)(fJyYk=E18FnTwi(u=h{jhRAN!pc^FyaVD0+8(p+4rCaI*rKx*uWO$a1Zy;yaB z+a`p&<*IwzU2=gJux)%{C7)jw=nEbA>NDl%MGHRZ$-B!nclS}?{ZR>cArq-5g(ppP zw{FocSTz~lKaB7u_k)V?fnE)5l0G*@dx}vSv8ZOJ|A9ywZxDOUtiU(4y)bBPn6Sv| z=Iucrl~}`R{KCJBXE=)*&f!m-#~Tb|4;SzjqpX5_ z;{!%4oVocPRVsIuxQ^~IBJ4C{bPL=c7w2y<6+Z;jUErXP1wcbVY7r?iVlAH6NcIuPyhe` literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..6a621cab1ef5eb46e7d6290d27779d1a1a608084 GIT binary patch literal 1079 zcmZuv+foxj5IvI(Y_co~g!?62y@VwpUh%@s5Wy-;0##5_@oh-P)MB!Wn+@o@f8mS2 zpbw!+s{8=I$+GMjP}Y<$Jv}|$=bY~8AHTkR2e6Dy0|_K`OhqtlAcUC+W+Rw0(2sd} zzoFx%fhdv&ZsE4{Qc*0xk_n5_OG}f{v7{rb;|@djs_oeRI)j#4c*PLTyH&vuFW8PK zwHimlJK#rk8Q~S*cAY)py>Y#Us4`5a3dj7EXZe|*6{o`SvpJQrCH)l%*1PZX%G)A8 zxxz5^-IiAo+qMLZZo5u(Ng|jS#1O-P^xtQjXSP$z?rgSv-*p)D2CosGO1ew>DjzsS zyN-Fw5hm{8zKI8T$k3;>)H&7e`yN5)ST^wpk4-$mQynWNRphAF5ah*NeFqTcv{>ahJCWh22BU z(vBuT`LyXFI%z4$4%6);G=%AVZk>Z&AXH9h=Li>+*F|1YdEMldti?9;Lo2OpM%qQI zjYwLWj5J>ehhc>55_-r+2sw%v42;r!4kl9QrMDQZRh(9*k2aZ%C8y#Q*>R literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..2971254ecf9e86c8366b5f99918ccc64d15505b4 GIT binary patch literal 644 zcmY*WU2oGc6g_UzW=+GsfNl&1W3Z7n6L|q%KuD-)(on`G6%_$bZfhn_ZGsYaMf@vX zGKoq20Dce8h~pM%BaY6!wvUg`z5ey*$4>yyu;=3%njY4CRBT-L;i73Lw=8T}xNYH% zg-r{0J>2uKB~W{zQ*B-fIANJO|H|E=k}oA%_jLk?Q2V3J|tNhqf(Y$E=7R_jyh$1Y@mTHy4#_@Hl4-v_JlhEH^{5t=3ncyhCBcO literal 0 HcmV?d00001 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 0000000000000000000000000000000000000000..a486c2fbf8d3401f1a6cf6f164211dc5230c3b8d GIT binary patch literal 559 zcmYLFT~8B16g|`3cH3ns0`eh>B8o07VR`aJ<4Z{sND-5gCc@LS9mtS&mTaeD{8zjz z2_*gie-F>bGgQOQ=G>1t_ug~o_n+He06riN5n&;~Vu+HnOCfwLxM11AGY2aUo;!FE zU^T!?fyyUswEZmL#hV=gzmfHoz)VXU^<_Nls{B}X2h8|Gsg1y5eA>E@-(@nuWafrxQNOp8n75DrL yR1(iC5G0iX)nvOsE%6J4k6qVMWqp;W#wj6IC~A$eHYjL|l2XnQm?x)%r+)#29Bg#} literal 0 HcmV?d00001 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