TODAY JAVA SCHOOL

In java school, programming, design, computer general knowledge, web application, software, web services, social media, digital marketing, oops, concept of programming language, oops feature, console media, graphics medium, first programming, c, c ++ , Java, PHP, SQL, MySQL, HTML, HTML_5, J_query, JavaScript, Bootstrap, Framework, images with logos, examples, shared and explained.

https://www.amazon.in/b?node=26373545031&linkCode=ll2&tag=1234567801cdb-21&linkId=3b9882431b00409b44141e0344b35a15&language=en_IN&ref_=as_li_ss_tl

Breaking

Saturday, 11 April 2020

Applet In Java | Life cycle Of Applet In Java | Applet In Java In Hindi

                                  Java Applet

Applet is a special type of program that is embedded in the webpage to generate the dynamic content. It runs inside the browser and works at client side.
An applet is a Java program that can be embedded into a web page. It runs inside the web browser and works at client side. An applet is embedded in an HTML page using the APPLET or OBJECT tag and hosted on a web server.
Applets are used to make the web site more dynamic and entertaining.

Advantage 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 plateforms, including Linux, Windows, Mac Os etc.


Drawback of Applet

  • Plugin is required at client browser to execute applet.

Applet life cycle in java
Fig: Applet In java

Lifecycle of Java Applet

1.    Applet is initialized.
2.    Applet is started.
3.    Applet is painted.
4.    Applet is stopped.
     5. Applet is destroyed.

These are method of life cycle of  a java.applet.Applet class

applet life cycle method in java

Fig: Lifecycle Of Applet

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.


How to run an Applet?

There are two ways to run an applet
1.    By html file.
2.    By appletViewer tool (for testing purpose).


Example of Applet by html file:

    //First.java  
    import java.applet.Applet;  
    import java.awt.Graphics;  
     public class First extends Applet{  

    public void paint(Graphics g){  
    g.drawString("welcome",150,150);  
       }               
      }
  

myapplet.html

    <html>  
    <body>  
    <applet code="First.class" width="300" height="300">    
    </applet>    
     </body>  
      </html>  

    Output:

                      Welcome

No comments:

Post a Comment