Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.Color;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.geom.Ellipse2D;
- import java.awt.geom.Rectangle2D;
- import javax.swing.JComponent;
- import javax.swing.JFrame;
- public class Auto {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- JFrame MainFrame=new JFrame("Autic");
- MainFrame.setSize(500,500);
- MainFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- MainFrame.setVisible(true);
- Slika auto = new Slika();
- MainFrame.add(auto);
- }
- }
- class Slika extends JComponent{
- public double x = 100;
- public double y = 100;
- public void paintComponent(Graphics a)
- {
- super.paintComponent(a);
- Graphics2D a2 = (Graphics2D)a;
- Rectangle2D prozori2 = new Rectangle2D.Double(x+10, y-40 +100, 130, 60);
- a2.setColor(Color.CYAN);
- a2.fill(prozori2);
- a2.draw(prozori2);
- Ellipse2D predjnideo = new Ellipse2D.Double(x+190, y-15+100, 95,55);
- a2.setColor(Color.PINK);
- a2.fill(predjnideo);
- a2.draw(predjnideo);
- Ellipse2D zadnjideo = new Ellipse2D.Double(x-50, y-15+100, 70,55);
- a2.setColor(Color.PINK);
- a2.fill(zadnjideo);
- a2.draw(zadnjideo);
- Rectangle2D telo = new Rectangle2D.Double(x-15, y-15+100, 250, 55);
- a2.setColor(Color.PINK);
- a2.fill(telo);
- a2.draw(telo);
- Rectangle2D okvirvrata1 = new Rectangle2D.Double(x+65, y-9+100, 80, 45);
- a2.setColor(Color.ORANGE);
- a2.fill(okvirvrata1);
- a2.draw(okvirvrata1);
- Rectangle2D ulaz1 = new Rectangle2D.Double(x+71, y-6+100, 69, 40);
- a2.setColor(Color.PINK);
- a2.fill(ulaz1);
- a2.draw(ulaz1);
- Rectangle2D rucica1 = new Rectangle2D.Double(x+90, y+100, 20, 5);
- a2.setColor(Color.GREEN);
- a2.fill(rucica1);
- a2.draw(rucica1);
- Ellipse2D guma1 = new Ellipse2D.Double(x-20 , y+100, 65, 65);
- a2.setColor(Color.GREEN);
- a2.fill(guma1);
- a2.draw(guma1);
- Ellipse2D guma2 = new Ellipse2D.Double(x+150 , y+100, 65, 65);
- a2.setColor(Color.GREEN);
- a2.fill(guma2);
- a2.draw(guma2);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement