Modal Box

Applet in java

Applet are intelligent programs that are used to load dynamic content in the webpage.
applet run on client side browser and they don’t need the main method to run.
applet has its own life cycle as the following methods :
1. init()
2. start()
3. paint()
4. stop()
5. destroy()

All Applet classes need to extend Applet class .

Applet class needs to be declared as public so, we need to save with the same as class name.
Applet class is embedded in the browser by using applet tag. For Applet class, the package java.applet needs to be imported.
 

Applet program for painting some shapes :

import java.applet.*;
import java.awt.*;
/*<applet code="MyApplet" width=600 height=400>
</applet> */ public class MyApplet extends Applet { public void paint(Graphics g) { g.drawString("welcome to applet",200,200); g.drawLine(300,150,400,400);// two points x and y co-ordintates g.drawRect(50,50,300,300); //First point co-ordinates and third point co-ordinates. } }

By command line applet class may be run by appletviewer command as following :

 > appletviewer MyApplet.java

⇒ out put is shown in 600 pixels as width and 400 as height windows of applet.

⇒ AWT controls like Button , Label etc may also be used for GUI programming design.

Video/ C Introduction

Watch video in full size
Wordpress Social Share Plugin powered by Ultimatelysocial