-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCadre.java
65 lines (51 loc) · 1.18 KB
/
Cadre.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import java.awt.Color;
import java.awt.Graphics;
import java.util.Vector;
import javax.swing.JPanel;
public class Cadre extends JPanel
{
//Couleur Fond
private Color couleur=Color.WHITE ;
//Objets
private Vector<Points> vect = new Vector<Points>();
public Cadre()
{
this.setBackground(couleur);
}
public void paintComponent(Graphics g)
{
super.paintComponent(g);
draw(g);
repaint();
}
public void draw(Graphics g)
{
for(int i=0; i<vect.size(); i++)
{
if(vect.get(i).getForme().equals("Rond"))
{
g.setColor(vect.get(i).getColor());
g.fillOval(vect.get(i).getPosX(), vect.get(i).getPosY(), vect.get(i).getSize(), vect.get(i).getSize());
}
if(vect.get(i).getForme().equals("Carre"))
{
g.setColor(vect.get(i).getColor());
g.fillRect(vect.get(i).getPosX(), vect.get(i).getPosY(), vect.get(i).getSize(), vect.get(i).getSize());
}
}
}
public void setColorFond(Color coli)
{
this.couleur=coli;
setVisible(false);
setVisible(true);
}
public void AddToVect(Points point)
{
vect.addElement(point);
}
public void removeAll()
{
vect.removeAllElements();
}
}