0% found this document useful (0 votes)
5 views20 pages

Create Cartoon Using Java Applet

The project report titled 'To Create Cartoon using Applet' details the development of Java applets for creating cartoon graphics. It includes acknowledgments, an introduction to applets, their lifecycle, graphics methods, color and font classes, and sample program codes for drawing characters like Doraemon and Mickey Mouse. The report is submitted by three students under the guidance of their professors at Sanjivani K.B.P. Polytechnic, Kopargaon.

Uploaded by

amolabak7
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)
5 views20 pages

Create Cartoon Using Java Applet

The project report titled 'To Create Cartoon using Applet' details the development of Java applets for creating cartoon graphics. It includes acknowledgments, an introduction to applets, their lifecycle, graphics methods, color and font classes, and sample program codes for drawing characters like Doraemon and Mickey Mouse. The report is submitted by three students under the guidance of their professors at Sanjivani K.B.P. Polytechnic, Kopargaon.

Uploaded by

amolabak7
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

A

PROJECT REPORT
ON
“To Create Cartoon using Applet”

Submitted By
Gawali Krushnakant jalindar (38)
Jadhav Sandip Dattatray (68)
Yeole Nishikant Madhukar (72)

Second Year Diploma in Computer Technology


Under the Guidence of
Ms. [Link]

Department Computer Technology,


SRES, Sanjivani K. B. P. Polytecnic, Kopergoan MSBTE,
Mumbai.

SANJIVANI RURAL EDUCATION SOCIETY’S


SANJIVANI K.B.P. POLYTECNIC, KOPERGOAN.

CERTIFICATE

This is to certify that, the project report entitled


“To Create Cartoon using Applet”

Submitted By
Gawali Krushnakant jalindar (38)
Jadhav Sandip Dattatray (68)
Yeole Nishikant Madhukar (72)

Ms. [Link]
[Link]
Project guide H.O.D. Computer
Tecnology
INDEX

[Link] Topic
1 Acknowledgment
2 Introduction
3 Life cycle applet
4 Graphics Method
5 Color class
6 Font Class
7 Running of applet
8 Program Code
9 Output
10 Conclusion
Acknowledgement

First and the foremost We , express our deep sense of gratitude, sincere
thanks and deep sense of appreciation to Project Guide [Link]
Department of Computer Technology. Sanjivani K.B.P. Polytechnic,
Kopargaon. Your availability at any time throughout the year, valuable
guidance, opinion, view, comments, critics, encouragement, and support
tremendously boosted this project work. Lots of thanks to Head,
Computer Technology Department, Prof. [Link] for providing us the
best support we ever had. We like to express our sincere gratitude to
[Link], Principal, Sanjivani K. B. P. Polytechnic, Kopargaon for
providing a great platform to complete the project within the scheduled
time. We are also Thankful to all the faculty members, Computer
Technology Department, Sanjivani K. B. P. Polytechnic, Kopargaon for
giving comments for improvement of work, encouragement and help
during completion of the Project. Last but not the least; We should say
thanks from my bottom of heart to our Family & Friends for their never
ending love, help, and support in so many ways through all this time.
Thank you so much.

Gawali Krushnakant
jalindar (38)
Jadhav Sandip Dattatray (68)
Yeole Nishikant Madhukar (72)
Diploma in Computer
Technology.
Sanjivani
[Link],kopergoan
Introduction

An applet is a Java program that runs in a Web browser. An applet can be


a fully functional Java application because it has the entire Java API at its
disposal.

Important points :

1. All applets are sub-classes (either directly or indirectly) of


[Link] class.
2. Applets are not stand-alone programs. Instead, they run within either a
web browser or an applet viewer. JDK provides a standard applet viewer
tool called applet viewer.
3. In general, execution of an applet does not begin at main() method.
4. Output of an applet window is not performed by [Link]().
Rather it is handled with various AWT methods, such as drawString().

• Advantages of Applet:
There are many advantages of applet. They are as follows:
➢ It works at client side so less response time.
➢ Secured.
➢ It can be executed by browsers running under many platforms,
including Linux, Windows, Mac Os etc.

• Drawback of Applet
➢ Plug in is required at client browser to execute applet.
• Lifecycle of Java Applet

• Life cycle methods for Applet:

The java. Applet. Applet class 4 life cycle methods and [Link]
Component class provides 1 life cycle methods for an applet.

java. applet. Applet class

For creating any applet java. applet. Applet class must be inherited. It
provides 4 life cycle methods of applet.
1. public void init(): is used to initialized the Applet. It is invoked only
once.
2. public void start(): is invoked after the init() method or browser is
maximized. It is used to start the Applet.
3. public void stop (): is used to stop the Applet. It is invoked when
Applet is stop or browser is minimized.
4. public void destroy(): is used to destroy the Applet. It is invoked only
once.
Graphics methods used

1. drawOval()

The method drawOval() is one of the methods of a Graphics object.


Syntax:
drawOval ( int x, int y, int width, int height );
fillOval( int x, int y, int width, int height );
Example:
drawOval (100,20,200,30);
fillOval( int x, int y, int width, int height );

This draws a circle or an oval that fits within the rectangle specified
by the x, y, width and height arguments. The oval is drawn inside a
rectangle whose upper left hand corner is at (x,y) and whose width
and height are as specified.

[Link]()

The drawRect method draws a rectangle outline for the given


position and size. We use the graphics context’s current color to
draw the rectangle’s outline color.
Syntax:
[Link](int x,int y,int width,int height);
[Link](int x,int y,int width,int height);
Example:
[Link] (50, 100, 60,200);
[Link](50, 100, 60,200);

Parameters:
• x: This is the rectangle’s x coordinate at which the rectangle is
started.
• y: This is the rectangle’s y coordinate at which the rectangle is
started.
•width This is the rectangle’s width.
• height: This is the rectangle’s height.

[Link]():-

The line is the simplest shape that we can draw with the Graphics
class. The drawLine() method takes two pair of coordinates (x1, y1)
and (y1, y2) as arguments and draws a line between them.
Syntax:
[Link] (x1, y2, x2, y2);
Example:
[Link] (10, 20, 10,100);

[Link]():-
Displays a text string.
Syntax:-
[Link](String str,int x,int y);
Example:-
[Link](“Welcome”,50,50);

[Link]():-
Draw a rounded corner rectangle.
 These methods takes 6 parametres, first four are similar to
drawRect() method. Two extra arguments represents the width
and height of angle of corners.
 These extra parameters indicates how much of corners will be
rounded.

Syntax:-
[Link](int x,int
y,width,height,[Link]);
[Link](int x,int y,width,height,[Link]);
Example:-
[Link](100,100,150,150,50,50);
[Link](100,100,150,150,50,50);
 Colors class:-

1. setColor(Color c):- is used to set the graphical current color


on applet.
Syntax:-
Void setColor(Color c);
Example:-
[Link]([Link]);

2. setBackground(Color c):- is used to set the background


color of the component.
Syntax:-

Void setBackground(Color c);


Example:-
[Link]([Link]);

3. setForeground(Color c):- is used to set the foreground


color of the component.
Syntax:-
Void setForeground(Color c);
Example:-
[Link]([Link]);

 Font class:-

Variables:-
Three protected varables access the font setting.
They are initially set through constructor. To read these variables,
use the Font class “get” method

1. Protected String name:- The name of the font.


2. Protected int size:-The size of the font.
3. Protected int style:-The Style of the font.
Constructor
public Font(String name,int style,int size)
example
Font f=new Font(“Century”,[Link],20);

Running an Applet in Java


Java Applet are compiled by javac command. It can be run by two ways,
but not with using java command. It can be run by using either java tool-
appletviewer or by loading Applet into web browser using applet tag in
html. Let us look into more details below :

1. Using Web Browser :

To view the applet in a web browser, you will require a java enabled
web browser. To enable java in
the browser, go to browser advanced setting an enable java. The
following steps should be followed :

a) Create an HTML file as above, containing the APPLET tag.


b) Compile the applet source code using javac.
c) Open the html file in the web browser

2. Using appletviewer :

It is a java tool provided to view applets. It is like a small browser


provided to have a preview of applet as they would look in [Link]
understands APPLET tag and used in the creation phase. The APPLET tag
should be written in source code file enclosing in comments. The
following steps should be followed:

a) Write HTML APPLET tag in comments in the source file.


b) Compile the applet source code using javac.
c) Use appletviewer [Link] to view the applet.
 Program
Code 1:
import [Link].*;
import [Link].*;
public class Doremon extends Applet
{
public void paint(Graphics g)
{
Font fn = new Font("Georgia", [Link],20);
[Link](fn);
[Link]("Doraemon Cartoon", 185, 500);
[Link]([Link]);
[Link](204,405,65,40);
[Link]([Link]);
[Link](204,405,65,40);
[Link]([Link]);
[Link](282,405,65,40);
[Link]([Link]);
[Link](282,405,65,40);
int
x[]={200,350,400,420,348,340,290,275,260,210,218,188,168};
int
y[]={250,250,200,220,300,420,420,380,420,420,310,360,340};
[Link]([Link]);
[Link](x,y,13);
[Link]([Link]);
[Link](x,y,13);
[Link]([Link]);
[Link](223,240,115,125);
[Link]([Link]);
[Link](223,240,115,125);
[Link](240,310,320,310);
[Link](240,270,80,80,180,180);
[Link]([Link]);
[Link](170,85,210,180);
[Link]([Link]);
[Link](170,85,210,180);
[Link]([Link]);
[Link](188,125,175,135);
[Link]([Link]);
[Link](188,125,175,135);
[Link]([Link]);
[Link](230,198,325,200);
[Link](230,155,95,87,180,180);
[Link]([Link]);
[Link](230,155,95,87,180,180);
[Link]([Link]);
[Link](255,214,50,40,-170,-170);
[Link]([Link]);
[Link](255,214,50,40,-170,-190);
[Link](255,227,48,15,180,180);
[Link]([Link]);
[Link](232,100,45,60);
[Link]([Link]);
[Link](232,100,45,60);
[Link]([Link]);
[Link](278,100,45,60);
[Link]([Link]);
[Link](278,100,45,60);
[Link]([Link]);
[Link](255,125,14,24);
[Link]([Link]);
[Link](285,125,14,24);
[Link]([Link]);
[Link](259,135,7,7);
[Link]([Link]);
[Link](288,135,7,7);
[Link]([Link]);
[Link](260,148,34,34);
[Link]([Link]);
[Link](260,148,34,34);
[Link]([Link]);
[Link](265,158,10,10);
[Link]([Link]);
[Link](265,158,10,10);
[Link](278,181,278,198);
[Link](310,170,368,150);
[Link](310,180,368,180);
[Link](310,190,368,210);
[Link](240,170,188,150);
[Link](240,180,188,180);
[Link](240,190,188,210);
[Link]([Link]);
[Link](215,248,120,15);
[Link]([Link]);
[Link](215,248,120,15);
[Link]([Link]);
[Link](260,250,40,40);
[Link]([Link]);
[Link](260,250,40,40);
[Link]([Link]);
[Link](274,270,10,10);
[Link]([Link]);
[Link](253,265,50,20,30,100);
[Link]([Link]);
[Link](158,330,40,40);
[Link]([Link]);
[Link](158,330,40,40);
[Link]([Link]);
[Link](390,190,40,40);
[Link]([Link]);
[Link](390,190,40,40);
}
}

/*
<applet code = "[Link]" width = "600" height = "520">
</applet>
*/
Code 2 :
import [Link].*;
import [Link].*;

public class Human extends Applet {

public void paint(Graphics g) {


// draw head
[Link]([Link]);
[Link](150, 50, 100, 100);

// draw eyes
[Link]([Link]);
[Link](175, 75, 10, 10);
[Link](215, 75, 10, 10);

// draw nose
[Link]([Link]);
[Link](195, 90, 10, 10);

// draw mouth
[Link]([Link]);
[Link](175, 100, 50, 30, 180, 180);

// draw body
[Link]([Link]);
[Link](160, 150, 80, 100);

// draw arms
[Link]([Link]);
[Link](110, 150, 50, 20);
[Link](240, 150, 50, 20);

// draw legs
[Link]([Link]);
[Link](180, 250, 20, 50);
[Link](220, 250, 20, 50);
}
}
/*
<html>
<applet>
<applet code="[Link]" width=600 height=700>
</applet>
</html>
*/

Code 3 :
import [Link];
import [Link].*;
public class MickeyMouseApplet extends Applet {
public void paint(Graphics g) {
// Set background color
setBackground([Link]);

// Draw head
[Link]([Link]);
[Link](50, 50, 200, 200);

// Draw ears
[Link](80, 20, 80, 80);
[Link](170, 20, 80, 80);

// Draw eyes
[Link]([Link]);
[Link](90, 90, 50, 50);
[Link](160, 90, 50, 50);
[Link]([Link]);
[Link](105, 105, 20, 20);
[Link](175, 105, 20, 20);

// Draw nose
[Link](130, 140, 40, 40);

// Draw mouth
Polygon mouth = new Polygon();
[Link](90, 160);
[Link](140, 180);
[Link](160, 180);
[Link](210, 160);
[Link](160, 220);
[Link](140, 220);
[Link](90, 160);
[Link](mouth);
}
}
/*
<html>
<applet>
<applet code=" [Link]" width=600
height=700">
</applet>
</html>
*/

Output:-

Output 1:
Output 2 :
Output 3 :
Conclusion:

By Using Applet We Created the different Cartoon with Multiple


colors.

You might also like