0% found this document useful (0 votes)
11 views

Cod in Java

The document defines a Java class that draws a truck using basic shapes like rectangles, ellipses and lines. The class overrides the paint method to draw the truck body as two rectangles, the wheels as ellipses and the base as a line. Text is also drawn on the truck bed.

Uploaded by

Medina Mesic
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Cod in Java

The document defines a Java class that draws a truck using basic shapes like rectangles, ellipses and lines. The class overrides the paint method to draw the truck body as two rectangles, the wheels as ellipses and the base as a line. Text is also drawn on the truck bed.

Uploaded by

Medina Mesic
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

import java.applet.

*;
import java.awt.*;
import java.awt.geom.*;

public class Kamion extends Applet


{ public void paint(Graphics g)
{
Graphics2D g2 = (Graphics2D) g;
Rectangle2D.Double rectangle =
new Rectangle2D.Double(50,100,120,80);
g2.setColor(Color.green);
g2.fill(rectangle);
g2.draw(rectangle);
Rectangle2D.Double rectangle1 =
new Rectangle2D.Double(170,130,80,50);
g2.setColor(Color.green);
g2.fill(rectangle1);
g2.draw(rectangle1);
Ellipse2D.Double backWheel =
new Ellipse2D.Double(70,160,40,40);
g2.setColor(Color.black);
g2.fill(backWheel);
g2.draw(backWheel);
Ellipse2D.Double frontWheel =
new Ellipse2D.Double(190,160,40,40);
g2.setColor(Color.black);
g2.fill(frontWheel);
g2.draw(frontWheel);
Line2D.Double baseLine =
new Line2D.Double(0,200,800,200);
g2.draw(baseLine);

Font f = new Font("Serif", Font.ITALIC, 25);


g2.setFont(f);
g2.setColor(Color.blue);
g2.drawString("Mesic",66,124);
g2.drawString("Spedicija",66,148);

}
}

You might also like