09/02/19

Membuat Rumah Dengan BlueJ Materi Komputer Grafik / Komgraf




import java.awt.*;
import javax.swing.*;
import java.awt.geom.*;
import java.awt.Graphics;
import java.awt.Color;
import java.awt.Font;
 public class Komgraf extends JPanel{
    public static void main(String[] args){
       JFrame f = new JFrame("Tugas Komgraf");
       f.setBackground(new Color(51,153,204));
        //f.getContentPane().setBackground(new Color(51,153,204));
       Komgraf bs = new Komgraf();
       f.getContentPane().add("Center",bs);
     
       f.pack();
       f.setSize(new Dimension(1000,1000));
       f.setVisible(true);
    }  
            public void paintComponent(Graphics g){
       
       
        Font f = new Font("Arial",Font.BOLD,18);
       
        g.setFont(f);
        g.drawString("Gedung Perkantoran",10,25);
        g.setFont(f);
        g.drawString("Dean Septiano",10,50);
        g.setFont(f);
        g.drawString("2015 4350 0172",10,75);
       

        Graphics2D g2d = (Graphics2D)g;
        Color warna3 = new Color(139,5,0); 
        Color warnaGedung2 = new Color(249,19,147);
        Color warnaGedung3 = new Color(0,255,254);

   
        GradientPaint warnaJendela = new GradientPaint(50,50,Color.black,100,0,Color.white,true);

        Shape jendela = new RoundRectangle2D.Double(125,225,75,75,5,5);
        Shape gedung1 = new RoundRectangle2D.Double(100,200,325,400,5,5);
        Shape gedung2 = new RoundRectangle2D.Double(400,300,225,300,5,5);
        Shape gedung3 = new RoundRectangle2D.Double(625,200,325,400,5,5);
        Shape trotoar = new RoundRectangle2D.Double(100,150,100,20,5,5);
        Shape trotoar2 = new RoundRectangle2D.Double(200,150,100,20,5,5);
 
   
        g.setColor(warna3);
        g2d.fill(gedung1);
   
        g2d.setPaint(warnaJendela);
        g2d.fill(new RoundRectangle2D.Double(125,225,75,75,5,5));
        g2d.setPaint(warnaJendela);
        g2d.fill(new RoundRectangle2D.Double(225,225,75,75,5,5));
        g2d.setPaint(warnaJendela);
        g2d.fill(new RoundRectangle2D.Double(325,225,75,75,5,5));
       
        g.setColor(Color.black);
        g2d.draw(gedung1);
   
            g.setColor(warnaGedung2);
            g2d.fill(gedung2);
            g.setColor(Color.black);
            g2d.draw(gedung2);

            g2d.setPaint(warnaJendela);
            g2d.fill(new RoundRectangle2D.Double(425,325,75,75,5,5));
            g2d.setPaint(warnaJendela);
            g2d.fill(new RoundRectangle2D.Double(525,325,75,75,5,5));
           
            g.setColor(warnaGedung3);
            g2d.fill(gedung3);
            g.setColor(Color.black);
            g2d.draw(gedung3);
            g2d.setPaint(warnaJendela);
            g2d.fill(new RoundRectangle2D.Double(650,225,75,75,5,5));
            g2d.setPaint(warnaJendela);
            g2d.fill(new RoundRectangle2D.Double(675,225,75,75,5,5));
            g2d.setPaint(warnaJendela);
            g2d.fill(new RoundRectangle2D.Double(825,225,100,75,5,5));
            g2d.setPaint(warnaJendela);
            g2d.fill(new RoundRectangle2D.Double(825,225,100,75,5,5));
           

            g.setColor(Color.red);
            g.fillRect(100,420,100 ,35 );
            g.setColor(Color.white);
            g.fillRect(100,450,100 ,35 );
            g.fillRect(100,450,5 ,150 );
           
            g.setColor(new Color(102,51,0));
            g.fillRect(50,525,9 ,60 );
            g.setColor(Color.green);
            g.fillOval(40,470, 30,40);
            g.fillOval(25, 500, 30,30);
            g.fillOval(50, 500, 30,30);
    }  
}



Tidak ada komentar:

Posting Komentar