/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package Oktober;
import java.awt.Canvas;
import java.awt.Color;
import java.awt.Font;
import java.awt.Frame;
import java.awt.Graphics;
/**
*
* @author compaq
*/
public class GambarDua extends Canvas {
public void paint(Graphics g)
{
Font f = new Font("Arial", Font.BOLD,16);
g.setFont(f);
g.setColor(Color.gray);
int x1[] = {8, 18, 212, 222, 222, 212, 18, 8 };
int y1[] = {18, 8, 8, 18, 402, 412, 412, 402 };
g.fillPolygon(x1, y1, 8);
g.fillOval(7, 7, 30, 30);
g.fillOval(192, 7, 30, 30);
g.fillOval(192, 382, 30, 30);
g.fillOval(7, 382, 30, 30);
g.setColor(Color.BLACK);
int x2[] = {10, 20, 210, 220, 220, 210, 20, 10 };
int y2[] = {20, 10, 10, 20, 400, 410, 410, 400 };
g.fillPolygon(x2, y2, 8);
g.fillOval(9, 9, 30, 30);
g.fillOval(190, 9, 30, 30);
g.fillOval(190, 380, 30, 30);
g.fillOval(9, 380, 30, 30);
g.setColor(Color.darkGray);
g.fillRect(80, 25, 70, 2);
g.fillRect(20, 65, 190, 280);
g.drawString("SAMSUNG", 75, 50);
g.drawLine(10, 355, 220, 355);
g.fillRect(97, 363, 34, 34);
g.setColor(Color.black);
g.fillRect(99, 365, 30, 30);
g.setColor(Color.lightGray);
int x3[] = {258, 268, 462, 472, 472, 462, 268, 258 };
int y3[] = {18, 8, 8, 18, 402, 412, 412, 402 };
g.fillPolygon(x3, y3, 8);
g.fillOval(257, 7, 30, 30);
g.fillOval(442, 7, 30, 30);
g.fillOval(442, 382, 30, 30);
g.fillOval(257, 382, 30, 30);
g.setColor(Color.DARK_GRAY);
int x4[] = {260, 270, 460, 470, 470, 460, 270, 260 };
int y4[] = {20, 10, 10, 20, 400, 410, 410, 400 };
g.fillPolygon(x4, y4, 8);
g.fillOval(259, 9, 30, 30);
g.fillOval(440, 9, 30, 30);
g.fillOval(440, 380, 30, 30);
g.fillOval(259, 380, 30, 30);
g.setColor(Color.lightGray);
g.fillOval(290, 40, 36, 36);
g.setColor(Color.black);
g.fillRect(358, 43, 5, 32);
g.fillRect(368, 43, 5, 32);
g.fillOval(293, 43, 30, 30);
g.drawString("SAMSUNG", 320, 350);
g.setColor(Color.darkGray);
g.fillOval(301, 51, 15, 15);
}
public static void main(String[] args) {
GambarDua gb2 = new GambarDua();
Frame f = new Frame();
f.setVisible(true);
f.add(gb2);
f.setSize(500, 550);
}
}
Oke Sekian artikel tentang menggambar di JAVA, sampai berjumpa lagi ya sobat catatanku ;)