Program sederhana berikut ini
merupakan contoh program java untuk menampilkan atau menggambar bentuk Oval
(Elips) di Java. Fungsi yang digunakan adalah drawOval() dan fillOval().
Berikut Source codenya :
01
|
import java.awt.*;
|
|
02
|
import javax.swing.*;
|
03
|
|
|
04
|
public class DrawOval
extends JFrame {
|
05
|
|
|
06
|
public DrawOval()
{
|
07
|
super ("Menggambar
Oval");
|
|
08
|
setSize
(400,165);
|
09
|
setVisible
(true);
|
|
10
|
}
|
11
|
|
|
12
|
public void paint
(Graphics g) {
|
13
|
super.paint
(g);
|
|
14
|
|
15
|
g.setColor
(Color.RED);
|
|
16
|
g.drawOval
(5, 40, 90, 50); //(x,y, width,height)
|
17
|
g.fillOval
(100, 40, 90, 50); //(x,y, width,height)
|
|
18
|
}
|
19
|
|
|
20
|
public static void main
(String args[]) {
|
21
|
DrawOval
test = new DrawOval();
|
|
22
|
test.setDefaultCloseOperation
(JFrame.EXIT_ON_CLOSE);
|
23
|
}
|
|
24
|
}
|
Thanks for reading & sharing KEPOIN IT
Menggambar Oval Di Javakepoin It >>>>> Download Now
ReplyDelete>>>>> Download Full
Menggambar Oval Di Javakepoin It >>>>> Download LINK
>>>>> Download Now
Menggambar Oval Di Javakepoin It >>>>> Download Full
>>>>> Download LINK