Al Ikhlas

1. Katakanlah : Dia-lah Allah, Yang Maha Esa 2. Allah adalah Tuhan yang bergantung kepada-Nya segala sesuatu 3. Dia tiada beranak dan tidak pula diperanakkan 4. Dan tidak ada seorangpun yang setara dengan Dia (Al-Qur'an Surat Al-Ikhlas 112)

Senin, 15 Juni 2015

program painter, menggambar sederhana "java"


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

public class Painter extends JFrame {
private int pointCount = 0;
private Point points[] = new Point[1000];

public Painter () {
super ("Program menggambar sederhana");

getContentPane().add(new JLabel("Drag mouse to draw"), BorderLayout.SOUTH);
addMouseMotionListener (
new MouseMotionAdapter() {
public void mouseDragged (MouseEvent e) {
if (pointCount < points.length) {
points[pointCount] = e.getPoint();
++pointCount;
repaint();
}
}
} //end of anonymous class
); //end method addMotionListener
setSize (300,150);
setLocationRelativeTo(null);
setVisible(true);
}

public void paint (Graphics g) {
super.paint(g);
for (int i = 0; i < points.length && points[i] != null; i++) {
g.setColor(Color.blue);
g.fillOval (points[i].x, points[i].y, 4,4);
}
}

public static void main (String args[]) {
Painter test = new Painter();
test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}

ARTIKEL TERKAIT :

Tidak ada komentar:

Posting Komentar