You are on page 1of 6

BINTANG LURUS

import java.awt.*;

import javax.swing.*;

public class latihan2 extends JPanel

public void paintComponent(Graphics g)

int q[] = {100,160,100};

int w[] = {100,120,140};

int e[] = {100,100,60};

int r[] = {140,200,150};

int t[] = {60,0,40,0,60,40};

int y[] = {150,170,120,70,90,120};

int p[] = {60,100,100};

int l[] = {90,40,100};

int qwe = e.length;

int rty = t.length;

int sgt = q.length;

int pl = p.length;

g.drawPolygon(q,w,sgt);

g.drawPolygon(e,r,qwe);

g.drawPolygon(t,y,rty);

g.drawPolygon(p,l,pl);

}
public static void main(String[]args)

JFrame f = new JFrame();

f.getContentPane().add(new latihan2());

f.setSize(500,500);

f.setVisible(true);

SOAL NO1 SORE

import java.awt.Color;

import java.awt.Graphics;

import javax.swing.JFrame;

public class UTS extends JFrame{

public UTS(){

//untuk nampilin frame

this.setSize(800, 600);

this.setDefaultCloseOperation(EXIT_ON_CLOSE);

this.setVisible(true);

@Override

public void paint(Graphics g) {

//membentuk grafis disini

g.drawRoundRect(10,30,145,30,10,10);

g.drawString("Wendy Hardiyanto",15,50);
g.drawRect(10,65,20,20);

g.drawRect(10,90,20,20);

g.drawRect(10,115,20,20);

g.drawRect(35,65,20,20);

g.drawRect(35,90,20,20);

g.drawRect(35,115,20,20);

g.drawRect(60,65,20,20);

g.drawRect(60,90,20,20);

g.drawRect(60,115,20,20);

g.drawRect(85,65,20,20);

g.drawRect(85,90,20,20);

g.drawRect(85,115,20,20);

g.drawRect(110,65,20,20);

g.drawRect(110,90,20,20);

g.drawRect(110,115,20,20);

g.drawRect(135,65,20,20);

g.drawRect(135,90,20,20);

g.drawRect(135,115,20,20);

g.fillOval(25,75,15,15);

g.fillOval(25,100,15,15);

g.fillOval(50,75,15,15);

g.fillOval(50,100,15,15);

g.fillOval(75,75,15,15);

g.fillOval(75,100,15,15);

g.fillOval(100,75,15,15);

g.fillOval(100,100,15,15);

g.fillOval(125,75,15,15);
g.fillOval(125,100,15,15);

g.fillOval(150,75,15,15);

g.fillOval(150,100,15,15);

g.drawRoundRect(10,140,145,30,10,10);

g.drawString("201943501455",15,155);

int x[] = {165,250,165};

int y[] = {65,100,135};

int nn = x.length;

g.fillPolygon(x,y,nn);

public static void main(String[] args) {

//membuat objek class

new UTS().setVisible(true);

NO2 BLM JADI

int q[] = {10,50,90};

int w[] = {50,10,50};

int e[] = {100,100,150};

int r[] = {150,100,150};

int t[] = {150,200,200};

int y[] = {150,100,150};


int sgt = q.length;

int er = e.length;

int ty = t.length;

g.setColor(Color.blue);

g.fillPolygon(q,w,sgt);

g.fillPolygon(e,r,er);

g.fillPolygon(t,y,ty);

g.fillRect(10,50,80,20);

BINTANG MIRING

import java.awt.*;

import javax.swing.*;

public class a extends JPanel

public void paintComponent(Graphics g)

int q[] = {200,140,200};

int w[] = {100,120,140};

int e[] = {200,200,230};

int r[] = {140,200,150};

int t[] = {230,200,200};

int y[] = {90,40,100};

int p[] = {230,290,250,290,230,250};

int l[] = {90,70,120,170,150,120};


int qwe = e.length;

int rty = t.length;

int sgt = q.length;

int pl = p.length;

g.drawPolygon(q,w,sgt);

g.drawPolygon(e,r,qwe);

g.drawPolygon(t,y,rty);

g.drawPolygon(p,l,pl);

public static void main(String[]args)

JFrame f = new JFrame();

f.getContentPane().add(new a());

f.setSize(500,500);

f.setVisible(true);

You might also like