push
This commit is contained in:
18
DEV2.1/CM1/Exercice4/Debut.java
Normal file
18
DEV2.1/CM1/Exercice4/Debut.java
Normal file
@@ -0,0 +1,18 @@
|
||||
//MELIANI SAMY (TP1)
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class Debut {
|
||||
public static void main(String[] args) {
|
||||
JFrame fenetre = new JFrame("");
|
||||
fenetre.setSize(650,650);
|
||||
fenetre.setLocation(0, 0);
|
||||
fenetre.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
|
||||
Debut2 appel1 = new Debut2();
|
||||
Debut3 appel2 = new Debut3(appel1);
|
||||
fenetre.addMouseListener(appel2);
|
||||
fenetre.add(appel1);
|
||||
fenetre.setVisible(true);
|
||||
}
|
||||
}
|
||||
30
DEV2.1/CM1/Exercice4/Debut2.java
Normal file
30
DEV2.1/CM1/Exercice4/Debut2.java
Normal file
@@ -0,0 +1,30 @@
|
||||
//MELIANI SAMY (TP1)
|
||||
import java.awt.Color;
|
||||
import java.awt.Graphics;
|
||||
import javax.swing.JComponent;
|
||||
|
||||
public class Debut2 extends JComponent {
|
||||
private int rayon;
|
||||
public Debut2(){
|
||||
super();
|
||||
rayon = 60;
|
||||
}
|
||||
|
||||
public void getrayon(int radius){
|
||||
this.rayon=radius;
|
||||
this.repaint();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void paintComponent(Graphics pinceau){
|
||||
Graphics secondPinceau=pinceau.create();
|
||||
if(this.isOpaque()){
|
||||
secondPinceau.setColor(this.getBackground());
|
||||
secondPinceau.fillRect(0, 0, this.getWidth(), this.getHeight());
|
||||
}
|
||||
secondPinceau.setColor(new Color(115,194,251));
|
||||
secondPinceau.fillRect(0,0,this.getWidth(),this.getHeight());
|
||||
secondPinceau.setColor(Color.YELLOW);
|
||||
secondPinceau.fillOval((this.getWidth()/2)-(this.rayon/2), (this.getHeight())-(this.rayon/2), this.rayon, this.rayon);
|
||||
}
|
||||
}
|
||||
23
DEV2.1/CM1/Exercice4/Debut3.java
Normal file
23
DEV2.1/CM1/Exercice4/Debut3.java
Normal file
@@ -0,0 +1,23 @@
|
||||
//MELIANI SAMY (TP1)
|
||||
import java.awt.*;
|
||||
import javax.swing.*;
|
||||
import java.awt.event.*;
|
||||
|
||||
public class Debut3 implements MouseListener{
|
||||
private int rayon;
|
||||
private Debut2 ref;
|
||||
public Debut3(Debut2 appel){
|
||||
super();
|
||||
this.rayon=60;
|
||||
this.ref=appel;
|
||||
}
|
||||
public void mouseEntered(MouseEvent evenement){}
|
||||
public void mousePressed(MouseEvent evenement){}
|
||||
public void mouseReleased(MouseEvent evenement){}
|
||||
public void mouseExited(MouseEvent evenement){}
|
||||
public void mouseClicked(MouseEvent evenement){
|
||||
this.rayon+=20;
|
||||
ref.getrayon(this.rayon);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user