DrawPolygons.java



//DrawPolygons.java

import java.awt.*;
import javax.swing.*;

public class DrawPolygons extends JFrame {

//
public DrawPolygons()
{
super(" DrawArcs ");
setSize( 400, 300 );
setVisible( true );
}

public void paint( Graphics g )
{
super.paint( g );

int xValue[] = { 20,40,50,10,20,15 };
int yValue[] = { 50,50,60,80,80,60 };
Polygon polygon1 = new Polygon( xValue, yValue, 6);

g.drawPolygon( polygon1 );

int xValue2[] = { 70,90,100,80,70,65,60 };
int yValue2[] = { 100,100,110,110,130,110, 90 };
g.drawPolygon( xValue2, yValue2, 7 );

int xValue3[] = { 120,140,150,190 };
int yValue3[] = { 40,70,80,60 };
g.drawPolygon( xValue3, yValue3, 4 );

Polygon polygon2 = new Polygon();
polygon2.addPoint ( 165, 135 );
polygon2.addPoint ( 175, 150 );
polygon2.addPoint ( 270, 200 );
polygon2.addPoint ( 200, 220 );
polygon2.addPoint ( 130, 180 );
g.fillPolygon( polygon2 );
}

public static void main( String arg[] )
{
DrawPolygons application = new DrawPolygons ();
application.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE );
}
}

Tinggalkan Balasan

Isikan data di bawah atau klik salah satu ikon untuk log in:

Logo WordPress.com

You are commenting using your WordPress.com account. Logout / Ubah )

Gambar Twitter

You are commenting using your Twitter account. Logout / Ubah )

Foto Facebook

You are commenting using your Facebook account. Logout / Ubah )

Foto Google+

You are commenting using your Google+ account. Logout / Ubah )

Connecting to %s