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

PROGRAM5

The document provides a Java applet program that demonstrates how to draw various shapes including ovals, rectangles, lines, and arcs. It includes method syntax for drawing and coloring shapes, as well as the source code for the applet. Instructions for compiling and running the applet are also provided.

Uploaded by

joyalprincess
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)
2 views

PROGRAM5

The document provides a Java applet program that demonstrates how to draw various shapes including ovals, rectangles, lines, and arcs. It includes method syntax for drawing and coloring shapes, as well as the source code for the applet. Instructions for compiling and running the applet are also provided.

Uploaded by

joyalprincess
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/ 2

PROGRAM-5

Write a Java Program to draw several shapes in the created windows. Applet
Program.

/*
Syntax for Methods used in this program
To draw Oval:
drawOval(int x, int y, int width, int height)
To change Pen Color:
setColor(Color c)
To color the Oval:
fillOval(int x, int y, int width, int height)
To draw rectangle:
drawRect(int x, int y, int width, int height)
To draw line:
drawLine(int x1, int y1, int x2, int y2)
To draw arc:
drawArc(int x, int y, int width, int height, int startAngle, int arcAngle)
*/

SOURCE CODE
import java.awt.*;
import java.applet.*;
public class PL5 extends Applet
{
public void paint(Graphics g)
{
g.setFont(new Font("Calibri", Font.BOLD,30));
g.drawString("Different Shapes in Applet", 20, 20);
g.drawOval(50,50,80,100);
g.setColor(Color.RED);
g.fillOval(50,50,80,100);
g.drawRect(150,150,120,100);
g.drawLine(270,270,350,350);
g.drawArc(60,280,100,80,180,180);
}
}
/* <applet code="PL5.class" width="400" height="400">
</applet>
*/
PROGRAM-5-OUTPUT
Compile :
Javac PL5.java
RUN:
appletviewer PL5.java

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy