Class Painter dapat digunakan untuk membuat program kecil yang membentuk garis dengan mouse (saat mouse di-drag).
Berikut ini tampilannya:
Berikut ini program lengkapnya:
02 | import java.awt.event.*; |
05 | public class Painter extends JFrame { |
06 | private int pointCount = 0 ; |
07 | private Point points[] = new Point[ 1000 ]; |
10 | super ( "Program menggambar sederhana" ); |
12 | getContentPane().add( new JLabel( "Drag mouse to draw" ), BorderLayout.SOUTH); |
14 | addMouseMotionListener ( |
15 | new MouseMotionAdapter() { |
16 | public void mouseDragged (MouseEvent e) { |
17 | if (pointCount < points.length) { |
18 | points[pointCount] = e.getPoint(); |
27 | setLocationRelativeTo( null ); |
31 | public void paint (Graphics g) { |
33 | for ( int i = 0 ; i < points.length && points[i] != null ; i++) { |
34 | g.setColor(Color.red); |
35 | g.fillOval (points[i].x, points[i].y, 4 , 4 ); |
39 | public static void main (String args[]) { |
40 | Painter test = new Painter(); |
41 | test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
Lagu Daerah Bengkulu Selatan
http://www.ziddu.com/download/17765598/PantaiPasarBawah.mp3.html
http://www.ziddu.com/download/17770609/Ading.mp3.html
http://www.ziddu.com/download/17770638/BatinLingiran.mp3.html
http://www.ziddu.com/download/17770712/BeghasKedurang.mp3.html
http://www.ziddu.com/download/17765528/MutighKupi.mp3.html
http://www.ziddu.com/download/17765460/KasiahSayang.mp3.html
http://www.ziddu.com/download/17765364/KemaneAgi.mp3.html
http://www.ziddu.com/download/17765259/KebilauBaliak.mp3.html
http://www.ziddu.com/download/17765180/KedurangBadakuDillahirka.mp3.html
http://www.ziddu.com/download/17764830/TukangKundai.mp3.html
http://www.ziddu.com/download/17764761/SukatanMatau.mp3.html
http://www.ziddu.com/download/17764705/Sinjang.mp3.html
http://www.ziddu.com/download/17764641/Seginim.mp3.html
http://www.ziddu.com/download/17764579/sekundangsetungguan.mp3.html
sumber: Radio Artha FM Bengkulu Selatan
Class Painter dapat digunakan untuk membuat program kecil yang membentuk garis dengan mouse (saat mouse di-drag).
Berikut ini tampilannya:
Berikut ini program lengkapnya:
02 | import java.awt.event.*; |
05 | public class Painter extends JFrame { |
06 | private int pointCount = 0 ; |
07 | private Point points[] = new Point[ 1000 ]; |
10 | super ( "Program menggambar sederhana" ); |
12 | getContentPane().add( new JLabel( "Drag mouse to draw" ), BorderLayout.SOUTH); |
14 | addMouseMotionListener ( |
15 | new MouseMotionAdapter() { |
16 | public void mouseDragged (MouseEvent e) { |
17 | if (pointCount < points.length) { |
18 | points[pointCount] = e.getPoint(); |
27 | setLocationRelativeTo( null ); |
31 | public void paint (Graphics g) { |
33 | for ( int i = 0 ; i < points.length && points[i] != null ; i++) { |
34 | g.setColor(Color.red); |
35 | g.fillOval (points[i].x, points[i].y, 4 , 4 ); |
39 | public static void main (String args[]) { |
40 | Painter test = new Painter(); |
41 | test.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); |
0 komentar:
Posting Komentar