Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // perun.dmi.rs/mitrovic/rg1.zip
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.image.BufferedImage;
- import java.io.IOException;
- import java.io.InputStream;
- import javax.imageio.ImageIO;
- import javax.swing.JFrame;
- import javax.swing.JPanel;
- @SuppressWarnings({"serial", "unused"})
- public class CicaGlisa extends JPanel
- {
- private BufferedImage image;
- public CicaGlisa()
- {
- try
- {
- InputStream input = getClass().getResourceAsStream("car.jpg");
- image = ImageIO.read(input);
- } catch (IOException e)
- {
- e.printStackTrace();
- System.exit(-1);
- }
- setBackground(Color.WHITE);
- }
- @Override
- protected void paintComponent(Graphics g) {
- super.paintComponent(g);
- //crtanje glOve
- g.setColor(Color.yellow);
- g.fillOval(120, 120, 100, 100);
- g.setColor(Color.black);
- g.drawOval(120, 120, 100, 100);
- //crtanje ociju
- g.setColor(Color.blue);
- g.fillOval(135, 145, 25, 20);
- g.setColor(Color.blue);
- g.fillOval(180, 145, 25, 20);
- //crtanje nosa
- g.setColor(Color.black);
- int[] xPoints = {170, 160, 180};
- int[] yPoints = {145, 180, 180};
- g.drawPolyline(xPoints,yPoints, 3);
- //crtanje usta
- g.setColor(Color.red);
- g.drawArc(145, 150, 50, 50, 230, 80);
- //crtanje tijela
- g.setColor(Color.black);
- g.drawLine(170, 220, 170, 350);
- //crtanje nogu
- g.setColor(Color.black);
- g.drawLine(170, 350, 130, 450);
- g.drawLine(170, 350, 210, 450);
- //crtanje ruku
- g.setColor(Color.black);
- g.drawLine(170, 265, 130, 350);
- g.drawLine(170, 265, 210, 350);
- //crtanje auta
- g.drawImage(image, 400, 180, null);
- //ispis teksta
- g.drawString("Ovo je cica glisa", 110, 490);
- }
- public static void main(String[] args) {
- JFrame frame = new JFrame();
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- frame.getContentPane().add(new CicaGlisa());
- frame.setSize(800, 600);
- frame.setTitle("Cica Glisa");
- frame.setVisible(true);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement