bukan apa2..hanya ingin berbagi.
siapa tau berguna buat yang lain..
:)
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author NURSIH
*/
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author NURSIH
*/
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.awt.font.*;
import java.awt.geom.*;
public class bunga extends JApplet{
public static void main(String s[]) {
JFrame frame = new JFrame();
frame.setTitle("watering flower");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
JApplet applet = new bunga();
applet.init();
frame.getContentPane().add(applet);
frame.pack();
frame.setVisible(true);
}
public void init() {
JPanel panel_er = new Panel2D();
getContentPane().add(panel_er);
}
}
class Panel2D extends JPanel{
public Panel2D() {
setPreferredSize(new Dimension(600, 650));
setBackground(Color.WHITE);
}
public void paintComponent(Graphics g) {
super.paintComponent(g);
Graphics2D g2 = (Graphics2D)g;
GeneralPath gp = new GeneralPath();
//awan
Shape s1 = new Ellipse2D.Double(40,10,40,40);
Shape s2 = new Ellipse2D.Double(70,10,40,40);
Shape s3 = new Ellipse2D.Double(100,10,40,40);
Area a1 = new Area(s1);
Area a2 = new Area(s2);
Area a3 = new Area(s3);
BasicStroke bsThickLine = new BasicStroke(7.0f);
g2.setStroke(bsThickLine);
g2.setPaint(new Color(107, 224, 241));
g2.draw(s1);
g2.draw(s2);
g2.draw(s3);
g2.fill (s1);
g2.fill (s2);
g2.fill (s3);
Shape s5 = new Ellipse2D.Double(230,30,90,70);
Shape s6 = new Ellipse2D.Double(290,30,90,70);
Shape s7 = new Ellipse2D.Double(350,30,90,70);
Area a5 = new Area(s5);
Area a6 = new Area(s6);
Area a7 = new Area(s7);
g2.setPaint(new Color(107, 224, 241));
g2.draw(s5);
g2.draw(s6);
g2.draw(s7);
g2.fill (s5);
g2.fill (s6);
g2.fill (s7);
//matahari
g2.setColor(new Color(246, 252, 2));
Shape matahari = new Ellipse2D.Double(450, 40, 70, 70);
g2.fill(matahari);
//gambar garis matahari
g2.setColor(new Color(255, 145,0));
g2.setStroke(new BasicStroke(3.0f));
g2.drawLine(485, 15, 485, 35);
g2.drawLine(425, 40, 445, 50);
g2.drawLine(520, 50, 540, 35);
g2.drawLine(420, 75, 440, 75);
g2.drawLine(525, 75, 545, 75);
g2.setColor(new Color(19, 65, 47));
BasicStroke bsGarisTebal1 = new BasicStroke(4.0f);
g2.setStroke(bsGarisTebal1);
g2.drawLine(265,350,265,550); // batang kiri
g2.drawLine(275,350,275,550); // batang kiri
g2.setColor(new Color(189, 92, 150));
Shape l1 = new Ellipse2D.Double(203,182,80,80); //kiri atas
g2.fill(l1);
Shape l2 = new Ellipse2D.Double(245,180,80,80); //atas
g2.fill(l2);
Shape l3 = new Ellipse2D.Double(295,210,80,80); //kanan atas
g2.fill(l3);
Shape l4 = new Ellipse2D.Double(288,260,80,80); //kanan bawah
g2.fill(l4);
Shape l5 = new Ellipse2D.Double(248,290,80,80); // bawah
g2.fill(l5);
Shape l6 = new Ellipse2D.Double(208,290,80,80); // bawah
g2.fill(l6);
Shape l7 = new Ellipse2D.Double(185,270,80,80); // kiri bawah
g2.fill(l7);
Shape l8 = new Ellipse2D.Double(180,230,80,80); // kiri bawah
g2.fill(l8);
float[] dashPattern;
float dashPhase = 0.0f;
dashPattern = new float[10];
dashPattern[0] = 4.0f;
dashPattern[1] = 5.0f;
dashPattern[2] = 8.0f;
dashPattern[3] = 5.0f;
dashPattern[4] = 12.0f;
dashPattern[5] = 5.0f;
dashPattern[6] = 16.0f;
dashPattern[7] = 5.0f;
dashPattern[8] = 20.0f;
dashPattern[9] = 5.0f;
BasicStroke bsBerpola = new BasicStroke(3.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL,2.0f,dashPattern, dashPhase);
dashPattern = new float[2];
dashPattern[0] = 20;
dashPattern[1] = 10; //Pendefinisian BasicStroke yang akan digunakan.
BasicStroke bsDashed = new BasicStroke(2.0f,BasicStroke.CAP_BUTT,BasicStroke.JOIN_BEVEL,2.0f,dashPattern,dashPhase);
g2.setStroke(bsDashed);
g2.setPaint(Color.blue); //air
gp.moveTo(80,150);
gp.quadTo(60,90,250,160);
gp.moveTo(80,150);
gp.quadTo(60,90,250,180);
gp.moveTo(80,160);
gp.quadTo(60,90,250,200);
gp.moveTo(80,160);
gp.quadTo(60,95,250,220);
g2.draw(gp);
dashPhase = 2.0f;
g2.setPaint(Color.black);
g2.drawLine(275,370,275,300); // garis putus2 bunga vertikal bawah
g2.drawLine(275,180,275,250); // garis putus2 bunga vertikal atas
g2.drawLine(180,275,250,275);// garis putus2 bunga horizontal kiri
g2.drawLine(300,275,370,275);// garis putus2 bunga horizontal kanan
BasicStroke bsGarisTebal = new BasicStroke(2.0f);
g2.setStroke(bsGarisTebal);
g2.drawLine(205,220,254,257); // vertikal kiri atas
g2.drawLine(325,215,292,257); // vertikal kanan atas
g2.drawLine(350,330,292,292); // vertikal kanan bawah
g2.drawLine(215,345,262,294); // vertikal kiri bawah
g2.setColor(new Color(102, 166, 215));
Shape siram = new Ellipse2D.Double(50,110,30,60); //siraman
g2.fill(siram);
g2.setColor(new Color(0, 80, 149));
g2.drawLine(60,114,60,168);
g2.drawLine(70,114,70,168);
g2.drawLine(55,125,75,125);
g2.drawLine(53,135,80,135);
g2.drawLine(50,145,78,145);
g2.drawLine(53,155,77,155);
g2.setColor(Color.gray);
Shape bb = new Rectangle2D.Double(0, 125, 50, 20);
g2.draw(bb);
g2.fill(bb);
g2.setColor(new Color(47, 132, 80));
Shape l9 = new Ellipse2D.Double(275,385,110,60); //daun
g2.fill(l9);
g2.setColor(new Color(0, 85, 52));
g2.drawLine(275,416,378,416);
g2.drawLine(295,416,330,390);
g2.drawLine(320,416,345,430);
g2.drawLine(340,416,370,400);
g2.setColor(new Color(129, 33, 120)); // putik
Shape s4 = new Ellipse2D.Double(253, 249, 50, 50);
g2.fill(s4);
//rerumputan
Ellipse2D.Double grass= new Ellipse2D.Double(350, 470, 360, 100);
g2.setColor(Color.GREEN);
g2.fill(grass);
g2.draw (grass);
Ellipse2D.Double grass2= new Ellipse2D.Double(10, 500, 300, 100);
g2.setColor(Color.green);
g2.fill(grass2);
g2.draw (grass2);
Ellipse2D.Double grass3= new Ellipse2D.Double(-10, 420, 200, 100);
g2.setColor(Color.GREEN);
g2.fill(grass3);
g2.draw (grass3);
//pagar
Line2D.Double pagar= new Line2D.Double(0,480,600,480);
Line2D.Double pagar1= new Line2D.Double(0,530,600,530);
g2.setColor(new Color(93,48 ,42 ));
g2.setStroke(new BasicStroke(10.0f));
g2.draw(pagar);
g2.draw(pagar1);
g2.drawLine(50,440,50,570);
g2.drawLine(100,440,100,570);
g2.drawLine(150,440,150,570);
g2.drawLine(200,440,200,570);
g2.drawLine(250,440,250,570);
g2.drawLine(300,440,300,570);
g2.drawLine(350,440,350,570);
g2.drawLine(400,440,400,570);
g2.drawLine(450,440,450,570);
g2.drawLine(500,440,500,570);
g2.drawLine(550,440,550,570);
//ceri
g2.setColor(Color.RED);
Ellipse2D.Double ceri1= new Ellipse2D.Double(170, 485, 10, 10);
g2.fill(ceri1);
Ellipse2D.Double ceri2= new Ellipse2D.Double(30, 450, 10, 10);
g2.fill(ceri2);
Ellipse2D.Double ceri3= new Ellipse2D.Double(60, 560, 10, 10);
g2.fill(ceri3);
Ellipse2D.Double ceri4= new Ellipse2D.Double(230, 540, 10, 10);
g2.fill(ceri4);
Ellipse2D.Double ceri5= new Ellipse2D.Double(70, 500, 10, 10);
g2.fill(ceri5);
Ellipse2D.Double ceri6= new Ellipse2D.Double(480, 500, 10, 10);
g2.fill(ceri6);
Ellipse2D.Double ceri7= new Ellipse2D.Double(570, 550, 10, 10);
g2.fill(ceri7);
g2.setColor(new Color (113,74,142));
Font font = new Font("Lucida Handwriting", Font.BOLD, 20);
g2.setFont(font);
g2.drawString("Nursih D. Hastuti", 350, 600);
g2.setColor(new Color (32,174,208));
Font font1 = new Font("King Education Center", Font.BOLD, 25);
g2.setFont(font1);
g2.drawString("09650015", 350, 630);
}
}
4 hari yang lalu
izin copaz ya... ane bingung mw buat awannya..
BalasHapusooh...mangga.
BalasHapushehehe..salah tu, mustinya awan yang putih..
tapi biar ga keliatan penggabungannya aja.