Advertisement
Guest User

marko

a guest
Feb 14th, 2016
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.10 KB | None | 0 0
  1. import java.awt.Color;
  2. import java.awt.Graphics;
  3. import java.awt.Graphics2D;
  4. import java.awt.geom.Ellipse2D;
  5. import java.awt.geom.Rectangle2D;
  6.  
  7. import javax.swing.JComponent;
  8. import javax.swing.JFrame;
  9.  
  10.  
  11. public class Auto {
  12.  
  13.     public static void main(String[] args) {
  14.         // TODO Auto-generated method stub
  15.  
  16.         JFrame MainFrame=new JFrame("Autic");
  17.         MainFrame.setSize(500,500);
  18.         MainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  19.         MainFrame.setVisible(true);
  20.        
  21.         Slika auto = new Slika();
  22.         MainFrame.add(auto);
  23.     }
  24. }
  25.     class Slika extends JComponent{
  26.        
  27.         public double x = 100;
  28.         public double y = 100;
  29.        
  30.        
  31.        
  32.    
  33.     public void paintComponent(Graphics a)
  34.     {
  35.         super.paintComponent(a);
  36.         Graphics2D a2 = (Graphics2D)a;
  37.        
  38.        
  39.        
  40.        
  41.         Rectangle2D prozori2 = new Rectangle2D.Double(x+10, y-40 +100, 130, 60);
  42.         a2.setColor(Color.CYAN);
  43.         a2.fill(prozori2);
  44.         a2.draw(prozori2);
  45.        
  46.        
  47.        
  48.         Ellipse2D predjnideo = new Ellipse2D.Double(x+190, y-15+100, 95,55);
  49.         a2.setColor(Color.PINK);
  50.         a2.fill(predjnideo);
  51.         a2.draw(predjnideo);
  52.        
  53.        
  54.         Ellipse2D zadnjideo = new Ellipse2D.Double(x-50, y-15+100, 70,55);
  55.         a2.setColor(Color.PINK);
  56.         a2.fill(zadnjideo);
  57.         a2.draw(zadnjideo);
  58.        
  59.        
  60.        
  61.         Rectangle2D telo = new Rectangle2D.Double(x-15, y-15+100, 250, 55);
  62.         a2.setColor(Color.PINK);
  63.         a2.fill(telo);
  64.         a2.draw(telo);
  65.        
  66.        
  67.         Rectangle2D okvirvrata1 = new Rectangle2D.Double(x+65, y-9+100, 80, 45);
  68.         a2.setColor(Color.ORANGE);
  69.         a2.fill(okvirvrata1);
  70.         a2.draw(okvirvrata1);
  71.        
  72.        
  73.         Rectangle2D ulaz1 = new Rectangle2D.Double(x+71, y-6+100, 69, 40);
  74.         a2.setColor(Color.PINK);
  75.         a2.fill(ulaz1);
  76.         a2.draw(ulaz1);
  77.        
  78.        
  79.         Rectangle2D rucica1 = new Rectangle2D.Double(x+90, y+100, 20, 5);
  80.         a2.setColor(Color.GREEN);
  81.         a2.fill(rucica1);
  82.         a2.draw(rucica1);
  83.        
  84.        
  85.         Ellipse2D guma1 = new Ellipse2D.Double(x-20 , y+100, 65, 65);
  86.         a2.setColor(Color.GREEN);
  87.         a2.fill(guma1);
  88.         a2.draw(guma1);
  89.        
  90.         Ellipse2D guma2 = new Ellipse2D.Double(x+150 , y+100, 65, 65);
  91.         a2.setColor(Color.GREEN);
  92.         a2.fill(guma2);
  93.         a2.draw(guma2);
  94.        
  95.        
  96.        
  97.        
  98.        
  99.     }
  100. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement