Download as pdf or txt
Download as pdf or txt
You are on page 1of 4

ZEAL EDUCATION SOCIETY’S

ZEAL POLYTECHNIC, PUNE.


NARHE │PUNE -41 │ INDIA

Applet Programming

// WAP FOR VARIOUS SHAPES IN APPLET

import java.awt.*;
import java.applet.*;
public class Graph1 extends Applet
{

public void paint(Graphics g)


{

// To draw a line use


g.drawLine(30,30,150,150);
g.drawString("Line 1",30,180);

// To draw a Rectangle
g.drawRect(200,30,100,100);
g.drawString("Rectangle 1",200,180);

g.fillRect(300,30,100,60);
g.drawString("Fill Rectangle 1",300,180);

1
ZEAL EDUCATION SOCIETY’S

ZEAL POLYTECHNIC, PUNE.


NARHE │PUNE -41 │ INDIA

// To draw a Circle or elipse


g.drawOval(30,300,100,100);
g.drawString("Circle 1",30,420);

g.drawOval(150,300,100,50);
g.drawString("Elipse 1",150,420);

// to draw Polygon
int x1[] = {300,400,300,400,350 };
int y1[] = {300,300,400,400,350};
g.drawPolygon(x1,y1,5);
g.fillPolygon(x1,y1,5);
g.drawString("Polygon",300,420);

// To draw a ARC
g.drawArc(450,30,70,100,150,80);
g.drawString(" Arc1",450,30);

g.fillArc(650,30,70,100,150,80);
g.drawString(" Arc 2",650,30);

2
ZEAL EDUCATION SOCIETY’S

ZEAL POLYTECHNIC, PUNE.


NARHE │PUNE -41 │ INDIA

// To draw a Cube
g.drawRect(500,400,100,100);
g.drawRect(550,450,100,100);
g.drawLine(500,400,550,450);
g.drawLine(500,500,550,550);
g.drawLine(600,400,650,450);
//g.drawLine(650,550,600,500);
g.drawString ("Cube ", 500,400);

}
}
/*
<applet code="Graph1.class" height=400 width=400>
</applet>
*/

OUTPUT:-
C:\JAVA_Practicals_2024>javac Graph1.java

C:\JAVA_Practicals_2024>appletviewer Graph1.java

3
ZEAL EDUCATION SOCIETY’S

ZEAL POLYTECHNIC, PUNE.


NARHE │PUNE -41 │ INDIA

You might also like