// penjelasan >> import java kegunaanya untuk bisa membaca coding jika tidak ada import di bawah maka program yang kita buat akan error
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
// public class untuk judul membuat aplikasi poligon jadi anda harus membuat terlebih dahulu class//
public class ContohPoligon extends JFrame {
public static void main(String[] args) {
ContohPoligon apl =
new ContohPoligon();
}
public ContohPoligon() {
super("Contoh Poligon"); // nama yang kita buat pertama kali
setSize(450, 300); // ukuran form yang akan kita buat terserah mau segedek mana anda buat
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
CanvasKu kanvas = new CanvasKu();
add(kanvas);
show();
}
}
class CanvasKu extends Canvas {
public void paint(Graphics g) {
int x[] = {10, 250, 50, 70,10};
int y[] = {10, 70, 130, 55,10};
int jumlah = x.length;
g.drawPolyline(x, y, jumlah);
for(int i=0; i<x.length; i++) {
x[i] += 150;
y[i] += 90;
}
g.setColor(Color.red); // warna untuk poligon yang kita buat
g.setColor(Color.decode("0xff00ff"));
g.fillPolygon(x, y, jumlah);
}
}
Contoh Coding Membuat Poligon Pada Java
Similar Posts
Samsung Xpress SL-M2825 Laser PrintersFast print speeds, a 12,000-page duty ... read more
Jun 09 2022
Samsung MultiXpress CLX-9251 Laser Multifunction PrinterPaper supply starts ... read more
Jun 07 2022
Samsung ProXpress SL-M4560 Laser Multifunction Printer Samsung ProXpress ... read more
Jun 05 2022
Samsung MultiXpress CLX-9256 Laser Multifunction Printer CLX-9256 scans of ... read more
Jun 03 2022
Dell C2665dnf Color Multifunction PrinterPrinter Category: LaserType: ... read more
May 22 2022
Recent Posts Widget
No comments:
Write comments