daily pastebin goal
29%
SHARE
TWEET

Untitled

a guest Mar 26th, 2019 77 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Berkas: ContohPoligon.java
  2.  
  3. import java.awt.*;
  4.  
  5. public class ContohPoligon extends Frame {
  6.    public static void main(String[] args) {
  7.       ContohPoligon apl =
  8.          new ContohPoligon();
  9.    }
  10.  
  11.    public ContohPoligon() {
  12.       super("Contoh Poligon");
  13.       setSize(350, 200);
  14.      
  15.       CanvasKu kanvas = new CanvasKu();
  16.       add(kanvas);
  17.  
  18.       show();
  19.    }
  20. }
  21.  
  22. class CanvasKu extends Canvas {
  23.  
  24.    public void paint(Graphics g) {
  25.       int x[] = {10, 250, 50, 70};
  26.       int y[] = {10, 70, 130, 55};
  27.      
  28.       int jumlah = x.length;
  29.       g.drawPolyline(x, y, jumlah);
  30.  
  31.       for(int i=0; i<x.length; i++) {
  32.          x[i] += 50;
  33.          y[i] += 20;
  34.       }
  35.  
  36.       g.drawPolygon(x, y, jumlah);
  37.    }
  38. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top