Upload
pm2214
View
6.806
Download
1
Tags:
Embed Size (px)
Citation preview
WELCOMEWELCOME
JAVA PRESENTATIONJAVA PRESENTATION
TOPIC OF PRESENTATIONTOPIC OF PRESENTATION
APPLETAPPLET
Created By :Created By : Prashant MarvaniaPrashant Marvania
Overview of APPLETOverview of APPLET
What is Applet?What is Applet? Advantages of AppletAdvantages of Applet Disadvantages of AppletDisadvantages of Applet The Life Cycle of an AppletThe Life Cycle of an Applet The format of <APPLET> tagThe format of <APPLET> tag Attributes of the <APPLET> tagAttributes of the <APPLET> tag Example of an AppletExample of an Applet
What is Applet?What is Applet?
Applet is a JAVA programme that can be Applet is a JAVA programme that can be embedded into HTML page.embedded into HTML page.
JAVA Applet runs on the java enables web JAVA Applet runs on the java enables web browsers such as MOZILA and INTERNET browsers such as MOZILA and INTERNET EXPLORER.EXPLORER.
Applets are used to make the web site more Applets are used to make the web site more dynamic and entertaining.dynamic and entertaining.
Advantages of AppletAdvantages of Applet
There are many advantages of Applet:There are many advantages of Applet: Cross platform and can run on Windows, Cross platform and can run on Windows,
MacOS and Linux platform. MacOS and Linux platform. Applet can work all the version of java plugin.Applet can work all the version of java plugin. Applets run in a sandbox.Applets run in a sandbox. Applets are supported by most web browsers.Applets are supported by most web browsers. Applets are cached in most web browsers.Applets are cached in most web browsers.
Disadvantages of AppletDisadvantages of Applet
There are many disadvantages of Applet:There are many disadvantages of Applet: Java plug-in is required to run Applet.Java plug-in is required to run Applet. Java Applet requires JVM.Java Applet requires JVM. If Applet is not already cached in the machine, If Applet is not already cached in the machine,
it will be downloaded from internet and will it will be downloaded from internet and will take time.take time.
Its difficult to design and build good user Its difficult to design and build good user interface in Applets compared to HTML interface in Applets compared to HTML technology. technology.
The Life Cycle of an AppletThe Life Cycle of an Applet
In Applet, there are 4 methods in Life Cycle:In Applet, there are 4 methods in Life Cycle:
1.init()1.init()
2.start()2.start()
3.stop()3.stop()
4.destroy()4.destroy()
Init() and start() methodsInit() and start() methods
Init():Init():
This method is called to initialized an This method is called to initialized an
Applet.Applet.
Start():Start():
This method is called after the This method is called after the
initialization of the Applet. initialization of the Applet.
Stop() and destroy() methodsStop() and destroy() methods
Stop():Stop():
This method can be called multiple This method can be called multiple
times in the life cycle of an Applet.times in the life cycle of an Applet.
Destroy():Destroy():
This method is called only once in This method is called only once in
the life cycle of an Applet when Applet the life cycle of an Applet when Applet
is destroyedis destroyed
The format of <APPLET> tagThe format of <APPLET> tag
<APPLET attributes><APPLET attributes>
applet_parametersapplet_parameters
alternate_contentalternate_content
</APPLET></APPLET>
Attributes of the <APPLET> tagAttributes of the <APPLET> tag
There are many attributes of the <APPLET> There are many attributes of the <APPLET> tag.tag.
1.CODE = appletFile1.CODE = appletFile 2.WIDTH = pixels2.WIDTH = pixels 3.HEIGHT = pixels 3.HEIGHT = pixels
Example of an AppletExample of an Appletimport javax.swing.*;import java.awt.*;import java.applet.*;/*<applet code=“ImageEx” height=100 width=100></applet>*/public class ImageEx extends Applet{ public void paint( Graphics g ) { Image img = getImage( getCodeBase( ), “ Lion.jpg" ); g.drawImage( img, 0,0, this ); } }
RUN THE APPLET:javac ImageEx.javaappletviewer ImageEx.java
Output of a programmeOutput of a programme
TOPIC OF PRESENTATIONTOPIC OF PRESENTATION
PACKAGEPACKAGE
Created By :Created By :Prashant MarvaniaPrashant Marvania
PackagesPackagesA package is a grouping of related types A package is a grouping of related types
providing access protection and name space providing access protection and name space management.management.
Types are special kinds of classes and Types are special kinds of classes and interfaces.interfaces.
You should bundle these classes and the You should bundle these classes and the interface in package for several reasons.interface in package for several reasons.
1.You and other programmers can easily determine 1.You and other programmers can easily determine that these types are related.that these types are related.
2.You and other programmers where to find types 2.You and other programmers where to find types that can provide graphics-related functions.that can provide graphics-related functions.
3.The name of your won’t conflict with the type 3.The name of your won’t conflict with the type names in other packages.names in other packages.
4.You can allow types within the package to have 4.You can allow types within the package to have unrestricted access to one another yet still restrict unrestricted access to one another yet still restrict access for types outside the package.access for types outside the package.
Creating a PackageCreating a Package
To create package, you choose a name for the To create package, you choose a name for the package and put a package statement with that package and put a package statement with that name the top of every source file that contains name the top of every source file that contains the types that you want to include in the the types that you want to include in the package.package.
Naming a PackageNaming a Package
With programmers worldwide writing classes With programmers worldwide writing classes and interfaces using the java programming and interfaces using the java programming language, it is likely that many programmers language, it is likely that many programmers will use the same name for different types.will use the same name for different types.
Naming ConventionsNaming Conventions
Package names are written in all lowercase to Package names are written in all lowercase to avoid conflict the names of classes or avoid conflict the names of classes or interfaces.interfaces.
Companies use their reversed internet domain Companies use their reversed internet domain name to begin their package names.name to begin their package names.
Package in the java language itself begin with Package in the java language itself begin with java or javax.java or javax.
Using package membersUsing package members
To use a public package member from outside To use a public package member from outside its package. you must do one :its package. you must do one :
1.Refer to the member by its fully qualified 1.Refer to the member by its fully qualified name.name.
2.Import the package member.2.Import the package member.
3.Import the member’s entire package.3.Import the member’s entire package.
Refer to packageRefer to package
Graphics. RectangleGraphics. Rectangle
You could use this name to create an instance You could use this name to create an instance of graphics. Rectangleof graphics. Rectangle
Graphics. Rectangle myrect=new Graphics. Graphics. Rectangle myrect=new Graphics. Rectangle ();Rectangle ();
Import a package memberImport a package member
To import a specific member into the current To import a specific member into the current file, put an import statement at the beginning file, put an import statement at the beginning of the file before any type definitions but after of the file before any type definitions but after the package statement, if there is one.the package statement, if there is one.
Import graphics. Rectangle;Import graphics. Rectangle;
Import entire packageImport entire package
To import all the types contained in a To import all the types contained in a particular package, use the import statement particular package, use the import statement with asterisk(*) wildcard character.with asterisk(*) wildcard character.
Import graphics.*;Import graphics.*;
Managing source and class filesManaging source and class files
Many implementations of the java platform Many implementations of the java platform rely on hierarchical file systems to manage rely on hierarchical file systems to manage source and class files, although the java source and class files, although the java language specification does not require this.language specification does not require this.
The qualified name of the package member The qualified name of the package member and the path name to the file are parallel, and the path name to the file are parallel, assuming the Microsoft windows file name assuming the Microsoft windows file name separator backslash.separator backslash.
Class nameClass name graphics. Rectangle graphics. Rectangle Pathname to filePathname to file graphics\Rectangle. java graphics\Rectangle. java
Each component of the package name Each component of the package name corresponds to a subdirectory.corresponds to a subdirectory.
It would be contained in a series of It would be contained in a series of subdirectories like this:subdirectories like this:
……\com\example\graphics\Reactangle.java\com\example\graphics\Reactangle.java
A class path may include several paths, A class path may include several paths, separated by a semicolon (windows) or colon separated by a semicolon (windows) or colon (UNIX).(UNIX).
By default the compiler and the jvm search the By default the compiler and the jvm search the current directory and the jar file containing the current directory and the jar file containing the java platform classes so that these directories java platform classes so that these directories are automatically in your class path.are automatically in your class path.
THANK YOUTHANK YOU