Tags

, , , , , ,

Interoduction of Applet

  • In java there are two types of programs 1.java aplication programs and 2. Applet. Whwere java application program resembleds any compiled language.
  • Example of progam is:
    class demo{

    public static void main(String args[]){

                                    System.out.println(“Hello!Demo!”)

    }             

    }

  • But other type of java program is applet. Applet are small parts of program which run as of webdocs.
  • Most of use of applet access from server side.it’s transfer from internet to user computer and automatically installed and run. Its used for multimedia interface. Applet coding as far different than java application.
  • Example of progam is:
    import java.awt.*;

    import java.applet.*;

    public class FirstDemoApplet extends Applet{

                    public void paint(Graphics g){

                                    g.drawstring(“FirstDemoApplet string”,50,30);

    }

    }

  • Lets applet programming:
    1. We always need two packages to imported in program. That is java.awt and java.applet.
    2. Where java.awt store component of awt classes. Its support for windows based GUI such as for drawing,screen,window, btton, textbox, menus etc.etc.
    3. And java.applet, this must need in applet program becuase, its store component in applet class. That have functionalities to run applet in web browser
    4. Then comes public class FirstDemoApplet extends Applet where FirstDemoApplet is subclass of class Applet. So that extends is used.first class need to public to run applet program.
    5. Public void paint(Graphic g) this method which painting something, its can be text, circle, rectangle, line anything.
    6. This menthod need pass perameter so passed object of class graphics is g. Using object method drawstring to display string,which is graphics class is invoked. Where 50.30 define the position of string , respectively x axis and yaxis.