BelahKetupat.java


//BelahKetupat.java
import java.awt.*;
import javax.swing.*;
public class BelahKetupat extends JFrame {
public BelahKetupat()
{
super(“Gambar Belah Ketupat “);
setSize( 500, 500 );
setVisible( true );
}
public void paint( Graphics g )
{
super.paint( g );

//belah ketupat
g.setColor( Color.RED );
int xValue2[] = { 50,250,450,250, 50 };
int yValue2[] = { 250, 50,250,450,250 };
Polygon polygon2 = new Polygon( xValue2, yValue2, 5);
g.fillPolygon( polygon2 );

g.setColor( Color.BLUE );
//Segiempat Bingkai Belah Ketupat
g.drawRect(50,50,400,400);
//diagonal belahketupat
g.drawLine(50,250,450,250);
g.drawLine(250,50,250,450);

}
public static void main( String arg[] )
{
BelahKetupat application = new BelahKetupat ();
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