An applet is a java program that runs in a web browsers. An applet can be fully functions java applications. Because it has the entire java API at it disposer.
There are some important difference between an applet and stand allows java applications.

  1. An applet is a java class that extends the java.applet.Applet
  2. The main method is not involved in the applet and an applet class can’t defind main.
  3. Applets are designed to be embedded with in a html base.
  4. When a user views an html page that contains an applet, the code for the applet downloads the user mission .
  5. A JVM is required to view an applet . the jvm can be either a plug in of the web browser are a separate run time environment.

Life cycle of an Applet :

This method is initiated for what ever initialization is needed for your applet .It is called after the pram. Tag inside the applet tag have been proceed.
This is automatically called after browsing calls the init method .It is also called when ever the user returns the page contining the applet having gon of the other pages.
This is automatically called when the user moves off the page or which the applets sheets. It can therefore the called repeatedly in the same applet.
This is only called length of browser normally, because applets are ment to live on html page , you should not normally leave resources behind after a user leaves the page that contains the applet.
It involved immediately after the stop method and also any time the applet needs to repaint it self in the browser the paint method actually inherited.

Example :
Import java.applet.*;
Import java.awt.*;
Public  class  hellow word applet.extends  applet
Public  void paint (Graphics g)
g.drawstring(“ hellow word” ,25 ,50);

Every applet is an extension of the bass applet class provides mehods that the derived applet class may call to obtain information and services from the browser contains using the applet classes.

Invoking an applet :

An applet may be invoked by embedding directives in on html file and we will the file throw an applet viewer are java enabled browser.
The code attitude of the tag is required. It specifies the applet class to run.width and height the height are also required to specify the intial size of the panal in which an applet runs. The applet directives nest be closed with a tag.
If an applet takes parameters ,values may be passed for the parameters, by adding tags between and . The browser ignores the text and other tags the applet tags. Non-java enabled browsers do not process and there fore anything that appers between the tags, not related to the applet, is visible is non-java enabled process.

S.NO Methode Discription
1Clear Rect ()Erasers a rectangular area of the convas
2Copy Area()Copies a rectangular area of the the canvas to another area
3Draw Arc()Draws a hollow arc
4Draw Line ()Draws a straight line
5Draw ovel ()Draws a hollow oval
6Draws polygon()Draws a hollow rectangle
7Draw rect()Draws a hollow rectangle.
8Draw round rect()Draws a hollow rectangle with rounded corner.
9Draw string()Displays a text string.
10Fill arc()Draw a filed arc
11Fill ovel()Draws a filled ovel
12Fill polygon()Draw a filled polygon
12Fill rect()Draw a filled rectangle
12Fill round rect()Draw a filled rectangle with rounded corners
12Get color()Retrives the current drawing color
12Get font()Retrives the currently used font
12Get font metrics()Retrives the information about the current font
12Set color()Sets the drawing color
12Set font()Sets the font.

         g. drawrect( x, y width ,height);
         g.draw oval (x,y,width,height,);
         g.set color(color, green);
         g.fill oval( x,y, width, height);
         g.draw arc(x,y, width, height, start angle, including, angle);

News Walls

Copyrights © 2016. All Rights Reserved to Learn Computers Home, India. //Site Designed.