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

Jaspreet Applet Assignment

This document contains 4 Java applet programs with HTML code. Each program displays different shapes and text on a canvas. The first program draws various shapes like ovals, rectangles, arcs, and polygons. The second program draws nested filled ovals in red and blue. The third draws ovals, rectangles, and a polygon. The fourth displays a message string along with rectangles on the canvas.

Uploaded by

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

Jaspreet Applet Assignment

This document contains 4 Java applet programs with HTML code. Each program displays different shapes and text on a canvas. The first program draws various shapes like ovals, rectangles, arcs, and polygons. The second program draws nested filled ovals in red and blue. The third draws ovals, rectangles, and a polygon. The fourth displays a message string along with rectangles on the canvas.

Uploaded by

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

Guru Nanak College,Budhlada

(Mansa)
Accredited by ‘A’ Grade

Java Assignment
On Applet Programming

Submitted To- Submitted By


Assist. Proff. Gagandeep Kaur Jaspreet Kaur
Dept. of Computer Science Roll No 2106
Gnc,Budhlada MCA 2

Department Of Computer Science


Guru Nanak College Bareta Jakhal Road
Budhlada 151502
1.Example using applet

Html code
**************

<html>
<title>Satnam Singh</title>
<body>
<hr>
<applet code="Satnam1.class" width="300" height="200">
<param name="image"value="java.jpg">
</applet>
</hr>
</body>
</html>

Java code
**********************
import java.applet.*;
import java.awt.*;

public class Satnam1 extends Applet


{
public void paint(Graphics g)
{
g.setColor(Color.red);
g.drawOval(600,160,30,90);
g.fillRect(400,9,70,40);
g.drawRect(190,6,50,50);
g.fillOval(800,160,70,170);
g.drawArc(500,160,190,290,100,80);
g.fillRoundRect(520,410,100,90,30,30);
g.drawOval(20,130,160,100);
int x2[]={200,120,280,240};
int z2=4,y2[]={260,370,370,270};
g.fillPolygon(x2,y2,z2);
g.drawLine(380,100,200,180);
}
}

Output:
********
2. Second program-

Html code-
**********
<html>
<title>deep</title>
<body>
<hr>
<applet code=Satnam2.class" width="300" height="200">
<param name="image"value="java.jpg">
</applet>
</hr>
</body>
</html>

Java code-
*************

import java.applet.*;
import java.awt.*;

public class Satnam2 extends Applet


{
public void paint(Graphics g)
{
g.setColor(Color.red);
g.fillOval(600,160,50,90);
g.setColor(Color.blue);
g.drawOval(600,250,50,90);
g.fillOval(600,340,50,90);
g.drawOval(600,430,50,90);
}
}

Output-
************

3. Third program

Html code-
**************

<html>
<title>Satnam</title>
<body>
<hr>
<applet code="Satnam3.class" width="300" height="200">
<param name="image"value="java.jpg">
</applet>
</hr>
</body>
</html>

Java code-
***************

import java.applet.*;
import java.awt.*;

public class Satnam3 extends Applet


{
public void paint(Graphics g)
{
g.drawOval(100,50,90,70);
g.drawOval(100,150,90,70);

g.drawRoundRect(500,80,90,90,200,200);
g.drawRect(250,90,150,90);
int x[]={320,350,390};
int y[]={380,320,390};
g.drawPolygon(x,y,3);

}
}

Output-
**************
4.Fourth Program

Html code-
**************

<html>
<title>Satnam</title>
<body>
<hr>
<applet code="Satnam_4.class" width="300" height="200">
<param name="image"value="java.jpg">
</applet>
</hr>
</body>
</html>

Java code –
*************

import java.applet.*;
import java.awt.*;
public class Satnam_4 extends Applet
{
String s = "Hello Satnam";
int x = 390;
int y = 290;

public void paint(Graphics g)


{

g.drawRect(250,190,250,190);
g.drawRect(450,190,50,50);
g.drawRect(400,190,50,50);
g.drawRect(350,190,50,50);
g.drawString(s, x, y);
g.drawRect(380,260,90,100);
}

Output-
**********

*********************

You might also like