appletsfd

Upload: omesh-dhanushka

Post on 02-Apr-2018

221 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/27/2019 appletsfd

    1/4

    New: JAXB | Junit

    Advertise Us | Ask Question | forum | login|

    Javatpoint Development | Training | SEO Promotion | Consultancy

    SSS IT (Powered by Javatpoint). Visit www.sssit.org for more details.

    0120-4256464, +91-999044

    Basics of Java

    OOPs Concepts

    String Handling

    Exception Handling

    Nested Classes

    Multithreading

    Synchronization

    I/O

    Serialization

    Networking

    AWT

    Event Handling

    Swing

    LayoutManager

    Applet

    Applet Basics

    Graphics in Applet

    Displaying image in

    Applet

    Animation in Applet

    EventHandling in

    Applet

    JApplet class

    Painting in Applet

    Digital Clock in Applet

    Analog Clock in

    Applet

    Parameter in Applet

    Applet

    Communication

    Reflection API

    Collection

    JDBC

    Java New Features

    RMI

    Internationalization

    Applet

    Advantage of Applet

    Drawback of Applet

    Hierarchy of Applet

    Lifecycle of an Applet:

    next>>

    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.

    There are many advantages of applet. They are as follows:

    l It works at client side so less response time.

    l Secured

    l It can be executed by browsers running under many plateforms, including Linux, Windows, Mac Os etc.

    l Plugin is required at client browser to execute applet.

    Do You Know ?

    l Who is respon sible to manage the l i fe cycle of an applet ?

    l How to perform animation in applet ?

    l How to paint l ike paint brush in applet ?

    l How to display digi tal clock in app let ?

    l How to display analog clock in applet ?

    l How to comm unicate two applets ?

    As displayed in the above diagram, Applet class extends Panel. Panel class extends Container which is the

    subclass of Component.

    ome Core Java Servlet JSP Struts2 Mail API Hibernate Spring Android Quiz Projects Interview Q Comment Forum

    http://www.javatpoint.com/Graphics-in-applethttp://www.javatpoint.com/internationalizationhttp://www.javatpoint.com/RMIhttp://www.javatpoint.com/New-features-in-javahttp://www.javatpoint.com/jdbc-tutorialhttp://www.javatpoint.com/collection-frameworkhttp://www.javatpoint.com/reflection1http://www.javatpoint.com/Applet-Communicationhttp://www.javatpoint.com/Parameter-in-applethttp://www.javatpoint.com/Analog-clock-in-applethttp://www.javatpoint.com/Digital-clock-in-applethttp://www.javatpoint.com/Painting-in-applethttp://www.javatpoint.com/JApplethttp://www.javatpoint.com/Event-Handling-in-applethttp://www.javatpoint.com/Animation-in-applethttp://www.javatpoint.com/Displaying-image-in-applethttp://www.javatpoint.com/Graphics-in-applethttp://www.javatpoint.com/applethttp://www.javatpoint.com/applethttp://www.javatpoint.com/LayoutManager-BorderLayouthttp://www.javatpoint.com/swinghttp://www.javatpoint.com/event-handlinghttp://www.javatpoint.com/awthttp://www.javatpoint.com/networkinghttp://www.javatpoint.com/serializationhttp://www.javatpoint.com/input-and-output-in-javahttp://www.javatpoint.com/synchronizationhttp://www.javatpoint.com/multithreadinghttp://www.javatpoint.com/difference-between-nested-classes-and-inner-classeshttp://www.javatpoint.com/exception-handling-and-checked-and-unchecked-exceptionhttp://www.javatpoint.com/string-handling-in-javahttp://www.javatpoint.com/java-oops-conceptshttp://www.javatpoint.com/java-what-where-and-whyhttp://www.javatpoint.com/forumhttp://www.javatpoint.com/comment.jsphttp://www.javatpoint.com/corejava-interview-questionshttp://www.javatpoint.com/free-java-projectshttp://www.javatpoint.com/examaccesshttp://www.javatpoint.com/android-tutorialhttp://www.javatpoint.com/spring-tutorialhttp://www.javatpoint.com/hibernate-tutorialhttp://www.javatpoint.com/java-mail-api-tutorialhttp://www.javatpoint.com/struts-2-tutorialhttp://www.javatpoint.com/jsp-tutorialhttp://www.javatpoint.com/servlet-tutorialhttp://www.javatpoint.com/java-what-where-and-whyhttp://www.javatpoint.com/http://www.sssit.org/http://www.sssit.org/http://www.javatpoint.com/http://feedburner.google.com/fb/a/mailverify?uri=javatpointsonoohttp://feeds.feedburner.com/javatpointsonoohttp://www.javatpoint.com/login.jsphttp://www.javatpoint.com/forumhttp://www.javatpoint.com/asknewquestion.jsphttp://www.javatpoint.com/advertise.jsphttp://www.javatpoint.com/junit-tutorialhttp://www.javatpoint.com/jaxb-tutorial
  • 7/27/2019 appletsfd

    2/4

    Lifecycle methods for Applet:

    java.applet.Applet class:

    java.awt.Component class:

    Who is responsible to manage the life cycle of an applet?

    How to run an Applet?

    Simple 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);

    }

    }

    Note: class must be pu blic because its object is created by Java Plugin so ftware that resides on

    the browser.

    1. Applet is initialized.

    2. Applet is started.

    3. Applet is painted.

    4. Applet is stopped.

    5. Applet is destroyed.

    The java.applet.Applet class 4 life cycle methods and java.awt.Component class provides 1 life cycle

    methods for an 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.

    The Component class provides 1 life cycle method of applet.

    1. public void paint(Graphics g): is used to paint the Applet. It provides Graphics class object that can

    be used for drawing oval, rectangle, arc etc.

    Java Plug-in software.

    There are two ways to run an applet

    1. By html file.

    2. By appletViewer tool (for testing purpose).

    To execute the applet by html file, create an applet and compile it. After that create an html file and place

    the applet code in html file. Now click the html file.

  • 7/27/2019 appletsfd

    3/4

    myapplet.html

    Live Demo:

    Simple example of Applet by appletviewer tool:

    //First.java

    import java.applet.Applet;

    import java.awt.Graphics;

    public class First extends Applet{

    public void paint(Graphics g){

    g.drawString("welcome to applet",150,150);

    }

    }

    /*

    */

    c:\>javac First.java

    c:\>appletviewer First.java

    To execute the applet by appletviewer tool, create an applet that contains applet tag in comment and

    compile it. After that run it by: appletviewer First.java. Now Html file is not required but it is for testing

    purpose only.

    To execute the applet by appletviewer tool, write in command prompt:

    next>>

    Tweet Like 16k

    Like the www.javatpoint.com on facebook / google+ / twitter / subscribe to get latest updates

    Sitemap Core Java Servlet JSP Struts2 Hibernate Spring Android Interview Questions

    javatpoint.com is developed to provide easy and point to point learning and training in detail. Examples might be simplified to improve reading and basic unTutorials and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. If there is any mistake, please mai

    [email protected] [email protected]. We provide assurance of 90% interview questions. While using this site, you agree to ha

    accepted our terms of use and privacy policy.

    2011-2013 Javatpoint. All Rights Reserved.

    http://feeds.feedburner.com/javatpointsonoohttp://feedburner.google.com/fb/a/mailverify?uri=javatpointsonoohttps://www.facebook.com/javatpointhttps://plus.google.com/u/0/113973042385691981314/postshttps://twitter.com/jaiswalsonoohttp://www.javatpoint.com/sitemap.xmlhttp://www.javatpoint.com/history-and-features-of-javahttp://www.javatpoint.com/servlet-tutorialhttp://www.javatpoint.com/jsp-tutorialhttp://www.javatpoint.com/struts-2-tutorialhttp://www.javatpoint.com/hibernate-tutorialhttp://www.javatpoint.com/spring-tutorialhttp://www.javatpoint.com/android-tutorialhttp://www.javatpoint.com/corejava-interview-questionshttp://www.javatpoint.com/corejava-interview-questionshttp://www.dmca.com/Protection/Status.aspx?ID=e8b533d5-7356-47f5-820b-72c890f03a4ehttp://www.javatpoint.com/http://www.javatpoint.com/corejava-interview-questionshttp://www.javatpoint.com/android-tutorialhttp://www.javatpoint.com/spring-tutorialhttp://www.javatpoint.com/hibernate-tutorialhttp://www.javatpoint.com/struts-2-tutorialhttp://www.javatpoint.com/jsp-tutorialhttp://www.javatpoint.com/servlet-tutorialhttp://www.javatpoint.com/history-and-features-of-javahttp://www.javatpoint.com/sitemap.xmlhttps://twitter.com/jaiswalsonoohttps://plus.google.com/u/0/113973042385691981314/postshttps://www.facebook.com/javatpointhttp://feedburner.google.com/fb/a/mailverify?uri=javatpointsonoohttp://feeds.feedburner.com/javatpointsonoohttps://twitter.com/sharehttp://www.javatpoint.com/Graphics-in-applet
  • 7/27/2019 appletsfd

    4/4