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
| package rev;
import java.awt.Color;
import java.awt.Graphics;
import java.awt.Polygon;
import javax.swing.JPanel;
public class PanneauGauche extends JPanel {
private int forme=0;
private Color cg;
public PanneauGauche(Gui gggg){
}
public void paintComponent(Graphics g){
super.paintComponent(g);
int xPoly[]={10,50,90};
int yPoly[]={150,250,150};
this.setBackground(cg);
Polygon poly = new Polygon(xPoly, yPoly, xPoly.length);
if (this.forme==1)
g.drawRect(10, 10, 50, 50);
if (this.forme==2)
g.drawOval(10, 70, 50, 50);
if(this.forme==3)
g.drawPolygon(poly);
}
public void setForme(int form){
this.forme=form;
}
public void setColor(Color c){
this.cg=c;
}
} |
Partager