aakash2310

Shapes

Mar 7th, 2022
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.67 KB | None | 0 0
  1. import java.applet.*;
  2. import java.awt.*;
  3.  
  4. public class Shapes extends Applet
  5. {
  6.     public void init()
  7.     {
  8.             setBackground(Color.cyan);
  9.             setForeground(Color.red);
  10.     }
  11.     public void paint(Graphics g)
  12.     {
  13.         // draw cone
  14.         g.drawOval(200,80,200,50);
  15.         g.drawLine(200,100,300,500);
  16.         g.drawLine(400,100,300,500);
  17.  
  18.         //draw cylinder
  19.         g.drawOval(500,60,200,50);
  20.         g.drawLine(500,80,500,300);
  21.         g.drawLine(700,80,700,300);
  22.         g.drawOval(500,280,200,50);
  23.  
  24.         //to draw cube
  25.         g.drawRect(500,400,100,100);
  26.         g.drawRect(550,450,100,100);
  27.         g.drawLine(500,400,550,450);
  28.         g.drawLine(500,500,550,550);
  29.         g.drawLine(600,400,650,450);
  30.         g.drawLine(650,550,600,500);
  31.     }
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment