Hi Leute habe mal ne frage kann ich zwei mal die methode paint verwenden??
Hier mein problem:
Würde gerne die beiden in ein programm machen weis aber nicht wie ?
Iwr sollen ein Programm schreiben das heist Meinekleine straße und soll uns ine straße mit häusern und bäumen zeigen. Dafür wollte ich die beiden halt in ein programm bekommen oder weis jemand eine andere lösung??
Wär sehr nett wen mir einer helfen könnte.
mfg timbo18
public void paint( Graphics g ){
Color stamm= new Color(149,84,72);
Color krone= new Color(101,159,62);
g.setColor(stamm);
g.fillRect(30,205,20,60);
g.setColor(krone);
g.fillOval(20,135,40,80);
g.setColor(stamm);
g.fillRect(90,205,20,60);
g.setColor(krone);
g.fillOval(80,135,40,80);
}
public void paint( Graphics g )
{ Color farbe=new Color(120,120,120);
Color farbe2=new Color(250,210,0);
Color farbe3=new Color(200,250,145);
Color farbe4=new Color(200,100,70);
Color farbe5=new Color(100,180,0);
Color dach=new Color(255,0,0);
//Hausunterteile
g.setColor(farbe);
g.fillRect(40,200,100,100);
g.setColor(farbe2);
g.fillRect(180,100,100,100);
g.setColor(farbe3);
g.fillRect(400,200,100,100);
g.setColor(farbe4);
g.fillRect(530,100,100,100);
g.setColor(farbe5);
g.fillRect(750,200,100,100);
//Dach
int[] ary1 = {200,200,150,150};
int[] ary2 = {100,100,50,50};
int[] arx = {30,150,90,90};
g.setColor(dach);
g.fillPolygon(arx,ary1,arx.length);
int[] arx1 = {170,290,230,230};
g.setColor(dach);
g.fillPolygon(arx1,ary2,arx1.length);
int[] arx2 = {390,510,450,450};
g.setColor(dach);
g.fillPolygon(arx2,ary1,arx2.length);
int[] arx3 = {520,640,580,580};
g.setColor(dach);
g.fillPolygon(arx3,ary2,arx3.length);
int[] arx4 = {740,860,800,800};
g.setColor(dach);
g.fillPolygon(arx4,ary1,arx4.length);
//Fenster1
Color fenster=new Color(255,255,255);
g.setColor(fenster);
g.fillRect(55,210,10,10);
g.fillRect(55,230,10,10);
g.fillRect(55,250,10,10);
g.fillRect(55,270,10,10);
g.fillRect(65,285,10,15);
g.fillRect(75,210,10,10);
g.fillRect(75,230,10,10);
g.fillRect(75,250,10,10);
g.fillRect(75,270,10,10);
g.fillRect(95,210,10,10);
g.fillRect(95,230,10,10);
g.fillRect(95,250,10,10);
g.fillRect(95,270,10,10);
g.fillRect(115,210,10,10);
g.fillRect(115,230,10,10);
g.fillRect(115,250,10,10);
g.fillRect(115,270,10,10);
// Fenster2
g.setColor(fenster);
g.fillRect(195,110,10,10);
g.fillRect(195,130,10,10);
g.fillRect(195,150,10,10);
g.fillRect(195,170,10,10);
g.fillRect(205,185,10,15);
g.fillRect(215,110,10,10);
g.fillRect(215,130,10,10);
g.fillRect(215,150,10,10);
g.fillRect(215,170,10,10);
g.fillRect(235,110,10,10);
g.fillRect(235,130,10,10);
g.fillRect(235,150,10,10);
g.fillRect(235,170,10,10);
g.fillRect(255,110,10,10);
g.fillRect(255,130,10,10);
g.fillRect(255,150,10,10);
g.fillRect(255,170,10,10);
//Fenster 3
g.fillRect(415,210,10,10);
g.fillRect(415,230,10,10);
g.fillRect(415,250,10,10);
g.fillRect(415,270,10,10);
g.fillRect(425,285,10,15);
g.fillRect(435,210,10,10);
g.fillRect(435,230,10,10);
g.fillRect(435,250,10,10);
g.fillRect(435,270,10,10);
g.fillRect(455,210,10,10);
g.fillRect(455,230,10,10);
g.fillRect(455,250,10,10);
g.fillRect(455,270,10,10);
g.fillRect(475,210,10,10);
g.fillRect(475,230,10,10);
g.fillRect(475,250,10,10);
g.fillRect(475,270,10,10);
//Fenster 4
g.fillRect(540,110,10,10);
g.fillRect(540,130,10,10);
g.fillRect(540,150,10,10);
g.fillRect(540,170,10,10);
g.fillRect(550,185,10,15);
g.fillRect(560,110,10,10);
g.fillRect(560,130,10,10);
g.fillRect(560,150,10,10);
g.fillRect(560,170,10,10);
g.fillRect(580,110,10,10);
g.fillRect(580,130,10,10);
g.fillRect(580,150,10,10);
g.fillRect(580,170,10,10);
g.fillRect(600,110,10,10);
g.fillRect(600,130,10,10);
g.fillRect(600,150,10,10);
g.fillRect(600,170,10,10);
//Fenster 5
g.fillRect(760,210,10,10);
g.fillRect(760,230,10,10);
g.fillRect(760,250,10,10);
g.fillRect(760,270,10,10);
g.fillRect(770,285,10,15);
g.fillRect(780,210,10,10);
g.fillRect(780,230,10,10);
g.fillRect(780,250,10,10);
g.fillRect(780,270,10,10);
g.fillRect(800,210,10,10);
g.fillRect(800,230,10,10);
g.fillRect(800,250,10,10);
g.fillRect(800,270,10,10);
g.fillRect(820,210,10,10);
g.fillRect(820,230,10,10);
g.fillRect(820,250,10,10);
g.fillRect(820,270,10,10);
}
Hier mein problem:
Würde gerne die beiden in ein programm machen weis aber nicht wie ?
Iwr sollen ein Programm schreiben das heist Meinekleine straße und soll uns ine straße mit häusern und bäumen zeigen. Dafür wollte ich die beiden halt in ein programm bekommen oder weis jemand eine andere lösung??
Wär sehr nett wen mir einer helfen könnte.
mfg timbo18
public void paint( Graphics g ){
Color stamm= new Color(149,84,72);
Color krone= new Color(101,159,62);
g.setColor(stamm);
g.fillRect(30,205,20,60);
g.setColor(krone);
g.fillOval(20,135,40,80);
g.setColor(stamm);
g.fillRect(90,205,20,60);
g.setColor(krone);
g.fillOval(80,135,40,80);
}
public void paint( Graphics g )
{ Color farbe=new Color(120,120,120);
Color farbe2=new Color(250,210,0);
Color farbe3=new Color(200,250,145);
Color farbe4=new Color(200,100,70);
Color farbe5=new Color(100,180,0);
Color dach=new Color(255,0,0);
//Hausunterteile
g.setColor(farbe);
g.fillRect(40,200,100,100);
g.setColor(farbe2);
g.fillRect(180,100,100,100);
g.setColor(farbe3);
g.fillRect(400,200,100,100);
g.setColor(farbe4);
g.fillRect(530,100,100,100);
g.setColor(farbe5);
g.fillRect(750,200,100,100);
//Dach
int[] ary1 = {200,200,150,150};
int[] ary2 = {100,100,50,50};
int[] arx = {30,150,90,90};
g.setColor(dach);
g.fillPolygon(arx,ary1,arx.length);
int[] arx1 = {170,290,230,230};
g.setColor(dach);
g.fillPolygon(arx1,ary2,arx1.length);
int[] arx2 = {390,510,450,450};
g.setColor(dach);
g.fillPolygon(arx2,ary1,arx2.length);
int[] arx3 = {520,640,580,580};
g.setColor(dach);
g.fillPolygon(arx3,ary2,arx3.length);
int[] arx4 = {740,860,800,800};
g.setColor(dach);
g.fillPolygon(arx4,ary1,arx4.length);
//Fenster1
Color fenster=new Color(255,255,255);
g.setColor(fenster);
g.fillRect(55,210,10,10);
g.fillRect(55,230,10,10);
g.fillRect(55,250,10,10);
g.fillRect(55,270,10,10);
g.fillRect(65,285,10,15);
g.fillRect(75,210,10,10);
g.fillRect(75,230,10,10);
g.fillRect(75,250,10,10);
g.fillRect(75,270,10,10);
g.fillRect(95,210,10,10);
g.fillRect(95,230,10,10);
g.fillRect(95,250,10,10);
g.fillRect(95,270,10,10);
g.fillRect(115,210,10,10);
g.fillRect(115,230,10,10);
g.fillRect(115,250,10,10);
g.fillRect(115,270,10,10);
// Fenster2
g.setColor(fenster);
g.fillRect(195,110,10,10);
g.fillRect(195,130,10,10);
g.fillRect(195,150,10,10);
g.fillRect(195,170,10,10);
g.fillRect(205,185,10,15);
g.fillRect(215,110,10,10);
g.fillRect(215,130,10,10);
g.fillRect(215,150,10,10);
g.fillRect(215,170,10,10);
g.fillRect(235,110,10,10);
g.fillRect(235,130,10,10);
g.fillRect(235,150,10,10);
g.fillRect(235,170,10,10);
g.fillRect(255,110,10,10);
g.fillRect(255,130,10,10);
g.fillRect(255,150,10,10);
g.fillRect(255,170,10,10);
//Fenster 3
g.fillRect(415,210,10,10);
g.fillRect(415,230,10,10);
g.fillRect(415,250,10,10);
g.fillRect(415,270,10,10);
g.fillRect(425,285,10,15);
g.fillRect(435,210,10,10);
g.fillRect(435,230,10,10);
g.fillRect(435,250,10,10);
g.fillRect(435,270,10,10);
g.fillRect(455,210,10,10);
g.fillRect(455,230,10,10);
g.fillRect(455,250,10,10);
g.fillRect(455,270,10,10);
g.fillRect(475,210,10,10);
g.fillRect(475,230,10,10);
g.fillRect(475,250,10,10);
g.fillRect(475,270,10,10);
//Fenster 4
g.fillRect(540,110,10,10);
g.fillRect(540,130,10,10);
g.fillRect(540,150,10,10);
g.fillRect(540,170,10,10);
g.fillRect(550,185,10,15);
g.fillRect(560,110,10,10);
g.fillRect(560,130,10,10);
g.fillRect(560,150,10,10);
g.fillRect(560,170,10,10);
g.fillRect(580,110,10,10);
g.fillRect(580,130,10,10);
g.fillRect(580,150,10,10);
g.fillRect(580,170,10,10);
g.fillRect(600,110,10,10);
g.fillRect(600,130,10,10);
g.fillRect(600,150,10,10);
g.fillRect(600,170,10,10);
//Fenster 5
g.fillRect(760,210,10,10);
g.fillRect(760,230,10,10);
g.fillRect(760,250,10,10);
g.fillRect(760,270,10,10);
g.fillRect(770,285,10,15);
g.fillRect(780,210,10,10);
g.fillRect(780,230,10,10);
g.fillRect(780,250,10,10);
g.fillRect(780,270,10,10);
g.fillRect(800,210,10,10);
g.fillRect(800,230,10,10);
g.fillRect(800,250,10,10);
g.fillRect(800,270,10,10);
g.fillRect(820,210,10,10);
g.fillRect(820,230,10,10);
g.fillRect(820,250,10,10);
g.fillRect(820,270,10,10);
}