0% found this document useful (0 votes)
16 views24 pages

Applet

Java applet pdf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
16 views24 pages

Applet

Java applet pdf
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 24
Bplet Applets are small Java program that are primarily used in internet Computing. They can be transported over the internet from one computer to another and run using the Applet Viewer or any web browser that support Java. It can perform arithmetic operations, display graphics, play sounds, accept user input, create animation etc. Java has enabled interactive multimedia web documents. A web page now contain not only a simple text or static image but also a java applet which can produce graphics, sounds and moving images. Java applets therefore have begun to make a significant impact on the WWW. Introduction Appet _2 Loca Osppter “= Local and Remote Applet Remote Applet An applet developed locally and stored in a local system is known as a local applet. When a web page is trying to find a local applet, it does not need to use internet and therefore the local system does not require the intemet connection. It simply searches the directories in the local system and locates and loads the specified applet. A remote applet is that which is developed by someone else and stored on a remote computer connected to the intemet. If our system is connected to the intemet, we can download the remote applet onto our system via the intemet and run it. In order to load a remote applet, we must know the applet's address ie. URL (uniform resource loggtor}. Introduction [aoa] 2 » Prbicin ? ~ Pxpplet 7 Applet doesn't have main() method unlike Applications. Unlike stand alone applications, applets cannot run independently. it needs web page using a special feature known as himl tag, Applets can not read from or write to the a file in local system. Applet can not communicate with other Servers on the network. Applets can not run a program from local computer. Applets are restricted from using libraries from other languages lke c/c++ etc. (But not~ that Java Supports the same using native methods.) Introduction Why we need Applet? 1. When we need to include something dynamic to included in our web page. 2. When we require some flash output like applet to produce some sound, animations or some special effects when displaying some certain pages. 3. When we want to create @ program and want it to make available on internet so that it could be used by others. Applet Life Cycle Every Java applet has a life cycle throught which it passes throughout his life span. Every Java applet inherits the behaviour from the Applet class. Applet life contains the following states: 1. Bor or initialization state 2. Running state 3. Idle state 4. Dead or destroyed state Applet Life Cycle __ _ Begin ‘Intization (Load Applet ton cei stopt) Display stort() paint() destroy() \pplet Life Cycle TT nitialization stats. When an applet is loaded, it enters the initiaization state. This happens by calling the init(/ method of Applet Class. Here, the Applet is born. AT this stage, the following actions may be taken’ 1. Create object as required by the Applet 2. Set up initial values 3. Load images or fonts 4. Setup colors Initialization occurs only once in the applet's life cycle. To go with any of the above points we need to override init) method: public void init() { (Action) Applet Life Cycle CGO Ca) =, SMT The winning state when the system calls the( tag 2. Incorporating tag into the web page. f. Creating HTML file Q. Testing the applet code. Let's Discuss all the above points in details Writing Java Applet C Urtffing Java Applet To create an applet we follow the following steps: 0. Building an applet code | java file) 7b. Creating an executable applet (.class file) ©. Designing a web page using HTML tags 7d. Preparing tag 2. Incorporating tag into the web page. _-t. Creating HTML file Q. Testing the applet code: << Combineal clip Let's Discuss all the above points in details Java Applet COD) Building an applet code (java fle) \dfically calls-c-series at Applet class methods for # ana stopping The hen Applet is loaded. The Applet clas therefore maintains the lifecycle of the cil meth ot ga-Applet class when-t-called. csnioa. the result of the pole! oocis on the screen. The cutout racibe ta, graphics or sound. The paint method and this requires the applet code imports “Thefjavacgwi package contained in the ~~ Grdphies#Ta5 ‘import fS e+ ult KY W Java Applet COD) '86, the structure may look like: Here drawstring is used to print a message ; _. _. . with 10 pixels on x amis and 100 pixels in y ineatiorawt Goplss 3b that means crewsting tones the import javagppiet; __, G@rpur argument ie. the valve fo be printed and Buble clas(idicsovd)extends Splat) two nls as xand y axts. Yelesardextends { public void paint(Graphic3 3) . _Public void Graphic} 3) Gy 1 1A Peawesinal Hello Java", 10, 100); (99) TOD ~ y } WwW ng Java Applet COD! In order to incorporate the .class file with the applet tag, so that it could be attached wi the HIML fle, we wiluse the folowing statement S/Bsdy 2 27 ttm Nov, we need to write complete HTML document by using al these concepts e. Incorporating tag into the web page. ‘ \ Working with Applet / too
-
<8 <(800% TM

You might also like