update
This commit is contained in:
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
Reference in New Issue
Block a user