Dalam kesempatan ini, saya akan membahas bagaimana cara membuat program menggambar beberapa garis dengan menggunakan bahasa java, dan menerapkannya dalam program NetBeans.
Untuk membuat beberapa garis dalam java dibutuhkan metode drawline yang terdiri beberapa baris dengan struktur penulisan:
drawline(x1, y1, x2, y2)
x1 dan y1 adalah titik garis awal dan x2 dan y2 adalah titik akhir garis. Dan untuk lebih jelasnya Kita ikuti contoh program dibawah ini dengan menggambar 6 gambar yaitu:
// Menggambar beberapa garis
import java.awt.*;
import java.applet.*;
/*
<applet code="Lines" width=300 height=200>
</applet>
*/
public class DemoGambarGaris extends Applet {
public void paint(Graphics g) {
g.drawLine(0, 0, 100, 100);
g.drawLine(0, 100, 100, 0);
g.drawLine(40, 25, 250, 180);
g.drawLine(75, 90, 400, 400);
g.drawLine(20, 150, 400, 40);
g.drawLine(5, 290, 80, 19);
}
}
Maka hasilnya seperti gambar dibawah ini:
Demikian cara membuat program menggambar beberapa garis dengan menggunakan bahasa java. Dan mudah-mudahan bermanfaat.
Terima Kasih
Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Java developer learn from Java Training in Chennai. or learn thru Java Online Training in India . Nowadays Java has tons of job opportunities on various vertical industry.
ReplyDeleteThere are so many useful information in your post, I like it all the time. And I want to share this boost app ranking with you, you can take a look. This is very useful.
ReplyDeleteShe advised me as a friend a small entertainment and part-time job on the Internet. I first doubted climbed the entire Internet in search of positive recalls and decided to take the risk and did not regret coming in and you will not regret successful gambling games good luck
ReplyDelete