screenshotnya :
Source Code
class main
package javaapplication3;
public class Main {
public static void main(String[] args) {
javax.swing.JFrame frame=new javax.swing.JFrame("Hardy Nugraha");
frame.setSize(350,350); frame.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(new keep_smile());
frame.setVisible(true);
}
}
public class Main {
public static void main(String[] args) {
javax.swing.JFrame frame=new javax.swing.JFrame("Hardy Nugraha");
frame.setSize(350,350); frame.setDefaultCloseOperation(javax.swing.JFrame.EXIT_ON_CLOSE);
frame.getContentPane().add(new keep_smile());
frame.setVisible(true);
}
}
class keep_smile
package javaapplication3;
import java.awt.BasicStroke;
import java.awt.Color;
public class keep_smile extends javax.swing.JComponent {
@Override
public void paint (java.awt.Graphics g){
java.awt.Graphics2D g2=(java.awt.Graphics2D) g;
//membuat lingkaran dengan warna kuning
g2.setColor(Color.YELLOW);
g2.fillOval(20,10, 300, 300);
g2.setStroke(new BasicStroke(5));//ketebalan stroke(garis) diset 5 pixel
g2.setColor(Color.gray);
g2.drawOval(20, 10, 300, 300);
//membuat mulut
g2.setColor(Color.black);
g2.fillArc(70, 100, 200, 180, 180, 180);
//mata kiri
g2.setColor(Color.black);
int[] x={75,160, 75};
int[] y={100,125,155};
g2.fillPolygon(x,y,3);
//mata kanan
g2.setColor(Color.black);
int[] x1={265,185, 265};
int[] y1={100,125,155};
g2.fillPolygon(x1,y1,3);
}
}
import java.awt.BasicStroke;
import java.awt.Color;
public class keep_smile extends javax.swing.JComponent {
@Override
public void paint (java.awt.Graphics g){
java.awt.Graphics2D g2=(java.awt.Graphics2D) g;
//membuat lingkaran dengan warna kuning
g2.setColor(Color.YELLOW);
g2.fillOval(20,10, 300, 300);
g2.setStroke(new BasicStroke(5));//ketebalan stroke(garis) diset 5 pixel
g2.setColor(Color.gray);
g2.drawOval(20, 10, 300, 300);
//membuat mulut
g2.setColor(Color.black);
g2.fillArc(70, 100, 200, 180, 180, 180);
//mata kiri
g2.setColor(Color.black);
int[] x={75,160, 75};
int[] y={100,125,155};
g2.fillPolygon(x,y,3);
//mata kanan
g2.setColor(Color.black);
int[] x1={265,185, 265};
int[] y1={100,125,155};
g2.fillPolygon(x1,y1,3);
}
}
Oke sekian dulu ulasan dari saya tentang cara membuat gambar/emoticon senyum menggunakan bahasa pemograman java, semoga bermanfaat buat agan-agan semua. Terima Kasih telah berkunjung semoga berhasil ya gan!