First Applet in java

First Applet 

Applet viewer is a command line program to run Java applets. It is included in the SDK. It helps you to test an applet before you run it in a browser. Before going any further, lets see what an applet is?
An applet is a special type of application that's included as a part of an HTML page and can be stored in a web page and run within a web browser. The applet's code gets transferred to the system and then the Java Virtual Machine (JVM) of the browser executes that code and displays the output.. So for running the applet,  the browser should be Java enabled. To create an applet, we need to define a class that inherits the Applet.
We generally use web browsers to run applets. Its not always mandatory to open a Web browser for running an applet. There is another way as well. The other way to run an applet is through Java applet viewer. This is a tool that acts as a test bed for Java applets. The working of Applet viewer is a bit different from a Web browser, though they are logically same. The Applet viewer runs on the HTML documentation, and uses embedded applet tags. The difference in using the applet viewer and the web browser to run the applet is that the applet viewer only deals with the applet code not the HTML cod i.e. it doesn't display HTML code. So we should test our program in applet viewer and web browser to confirm its working.
The applet viewer command connects to the documents or resources designated by urls. It displays each applet referenced by the documents in its own window.
Java version of Applet is given bellow :
import java.awt.*;
import javax.swing.*;
public class AppletTest extends JApplet{

public void init(){
 setLayout(new BorderLayout());
 JLabel label=new JLabel("First Applet Test");
// TODO overwrite start(), stop() and destroy() methods

Post a Comment

Thank you for vising

Previous Post Next Post