Applet(java) inner and deep conceptual meaning

                                                  Applet 


Before staring about the discussion about applet first i would like to give the introduction about the applications . 

First of all at at primary level we have two types of application 

1)Desktop based application
2)web based application

1)Desktop based application:- defining in simple terms desktop applications are the applications                                                          whose output is seen on the desktop.

2)web based application:- web based application are those application whose output is seen on the                                                  web browser.

Now as we all now that applet is somewhat related to website than why i didn't distinguished as Desktop application and applet.The reason is that a web page is the collection of different components or we can say that a web page is made up of different different tools ,

As far as we know to keep anything for example we say for a cup of tea we need a table as a base as a background  otherwise there is no use of it so we can say that applet is the container or background for the browser applications so all the tools such as buttons,text box, rich text box,drop down menu ,list,etc are kept on it.

 So inshort Applet is the background for web-based application or a web page where as a frame is the background for desktop based working .

In windows we say form is the background.

 The name frame in desktop , we gave the name form  for windows there is no difference between the concept of the two.

Comming back for the Applet first of all Applet is nothing new but the ready made class provided by java in java.applet  package so we have to take the class Applet by importing the java.applet package.

First thing the web based application or website is run in browser so browser supports html php .net etc extensions file while in java we have the product Applet which is in java so normally we have .class file in java and browser dosent support .class file so something must be done to give our java file in which the code of how to prepare an applet is written.

Now in mid of 2005 all the language such as php, asp.net etc came to picture but before that we have only language called HTML(hyper text markup language ) and java wanted to make Applet run in browser so by default browser is the compiler which converts the html code to the machine code .So now as far as html is concerned the code we write in it is in two forms follwed by their structure for that we have single and pair tags .

for eg we write <html>.......</html>  ----------> called pair tag which has starting as well as ending tag for single tag we dont have ending tag .

This was the example that how we create the structure of HTML 

By just saving the file as .html dosent mean that we have converted that file in html

Something must be applied in that java code so that it follows the html structure for that james goosling the creater of java gave alternative so that its Applet could run in browser for that he gave Applet tag as

                                 <applet code= classfilenm width= in pixels height in pixels>

                                   </applet>

This is the small code in html behind it .

Now we see again how to make applet nothing is hard in making an applet just the code for an applet is written in the method in the class file of Applet .That Applet class we have to inherit in any normal class we difine thats the only thing we need to do.

question might arise doing this only will create an Applet....... yes it will.... the method inside the class Applet is setStub has the code for how to write an Applet so as the class is inherited the method is followed automatically.

example


import java.applet.Applet;
            OR
import java.applet.* //so all the class are included in the applet package 

 class abc extends Applet
{

}

Now we have written nothing in the above class

so lets compile it by javac abc.java it will compile as it sees only the class keyword and will make .class file that is abc.class file it cannot run as it does not have main() method in it .

Now open notepad and write 

<html>
<body>
   <applet code= abc width= 300  height=200>
</applet>
</body>
</html>

save this file by giving extension as .html and run in your available browser ..

Internal working about working about the Applet that is how it works 
See one thing u might all have noticed that we wrote height and width outside not in the java code we designed in appelet that is in the empty body why...??

The reason for this is..

Lets take  an example if one person wants to make his website so the whole code is in html but some of the portion is  in java that is the content which is important and he always wanted to be displayed as java is platform independent now the programmer is the specialized one in html so he hires other person for java content now the person who gave website , views it and if changes is made in the java block then every time the html programmer has to consult the java programmer for the setting of hight and width , Every time the new class file with changes is given and vice versa so it becomes tidious job and by the facility here the html programmer can give the height and width explicitly .  

Now what does the code=classfilenm do...??

 It calls setStub method so it is called run time system calling .And the height and width goes as an argument .

lets think how that method might be made for that 

final void setStub(appletstub stubobj)
{
   //here the code is written for an applet and it cannot be overriden and appletstub is the class and the object stubobj
}

here to check output of your applet java has provided a tool called applet viewer.

hope u all might have understood the concept internally what is applet and how it is generated give ur feedbacks if any 

Comments

Popular posts from this blog

State space search / blocks world problem by heuristic approach /TIC TAC TOE

Navigation in Vaadin.

Drag and drop items from one Grid to another