You are on page 1of 6

package pertemuan1;

import java.awt.Color;
import javax.swing.JFrame;
import javax.swing.JPanel;
import java.awt.Graphics;
public class heli extends JFrame {
public heli() {
setTitle("DrawArcs");
add(new ArcsPane());

}
/** Main method */
public static void main(String[] args) {
heli frame = new heli();

frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(1000, 1500);
frame.setVisible(true);
}
}
// The class for drawing arcs on a panel
class ArcsPane extends JPanel {
// Draw four blazes of a fan
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
int xCenter = getWidth() / 2;
int yCenter = getHeight() / 2;
int titikX[] =

{600,850,850,600};

int titikY[] = {300,300,350,400};

//Background

g.setColor(Color.black);

g.fillRect(0, 0, 1024, 1000);


g.setColor(Color.yellow);
g.fillRect(0, 450, 1024, 268);
g.setColor(Color.yellow);
g.fillOval(500,200,10,10);
g.setColor(Color.yellow);
g.fillOval(600,100,10,10);
g.setColor(Color.yellow);
g.fillOval(800,50,10,10);
g.setColor(Color.yellow);
g.fillOval(200,70,10,10);
g.setColor(Color.yellow);
g.fillOval(150,60,10,10);
g.setColor(Color.yellow);
g.fillOval(900,60,10,10);
g.setColor(Color.yellow);
g.fillOval(900,100,10,10);
g.setColor(Color.yellow);
g.fillOval(50,50,10,10);

int [] t = {0, 128, 400, 690, 1024, 1024,0};


int [] n = {300, 400, 310, 400, 320, 450,450};
g.setColor(Color.darkGray);
g.fillPolygon(t, n, 7);

g.drawPolygon(t, n, 7);

int [] x = {0, 200, 400, 690, 1024, 1024,0};


int [] y = {320, 400, 300, 380, 350, 450,450};
g.setColor(Color.green);
g.fillPolygon(x, y, 7);
g.drawPolygon(x, y, 7);

int [] a = {0, 448, 650, 0};


int [] b = {450, 450, 700, 718};
g.setColor(Color.black);
g.fillPolygon(a, b, 4);
g.drawPolygon(a, b, 4);

int [] c = {548, 750, 896, 694};


int [] d = {450, 700, 700, 450};
g.setColor(Color.black);
g.fillPolygon(c, d, 4);
g.drawPolygon(c, d, 4);

//Helikopter
g.setColor(Color.blue);
g.fillArc(100, 100, 600, 100, 0, 360);
g.setColor(Color.red);
g.fillArc(100, 100, 600, 100, 0, 50);
g.setColor(Color.red);
g.fillArc(100, 100, 600, 100, 70, 45);
g.setColor(Color.red);
g.fillArc(100, 100, 600, 100, 130, 45);
g.setColor(Color.red);
g.fillArc(100, 100, 600, 100, 210, 45);
g.setColor(Color.red);
g.fillArc(100, 100, 600, 100, 270, 45);
g.setColor(Color.black);
g.fillArc(370, 140, 50, 30, 0, 180);
g.setColor(Color.blue);
g.fillPolygon(titikX, titikY, titikX.length);
g.setColor(Color.red);
g.fillRoundRect(220, 550, 350 ,40 ,40,90);
g.setColor(Color.magenta);
g.fillOval(150, 200, 500, 400);
g.setColor(Color.red);
g.fillRoundRect(220, 600, 350 ,40 ,40,90);
g.setColor(Color.yellow);

g.fillRect(370, 200, 50, 30);


g.setColor(Color.white);
g.fillOval(150, 270, 240, 270);
g.setColor(Color.orange);
g.fillOval(180, 280, 140, 150);
g.setColor(Color.white);
g.fillOval(800,250 ,150, 150);
g.setColor(Color.red);
g.fillArc(800, 250, 150, 150, 0, 50);
g.setColor(Color.red);
g.fillArc(800, 250, 150, 150, 70, 50);
g.setColor(Color.red);
g.fillArc(800, 250, 150, 150, 140, 50);
g.setColor(Color.red);
g.fillArc(800, 250, 150, 150, 210, 50);
g.setColor(Color.red);
g.fillArc(800, 250, 150, 150, 285, 50);
g.setColor(Color.black);
g.fillOval(850,300 ,40,40);

}
}

You might also like