Home Java Example Java Applet Java Applet - Creating First Applet Example
Questions:Ask|Latest

 
 

Share on Google+Share on Google+

Java Applet - Creating First Applet Example

Advertisement
First of all we will know about the applet. An applet is a program written in java programming language and embedded within HTML page.

Java Applet - Creating First Applet Example

     

Introduction

First of all we will know about the applet. An applet is a program written in java programming language and embedded within HTML page. It run on the java enabled web browser such as Netscape navigator or Internet Explorer.

In this example you will see, how to write an applet program. Java source of applet is then compiled into java class file and we specify the name of class in the applet tag of html page. The java enabled browser loads class file of applet and run in its sandbox.

Here is the java code of program :

import java.applet.*;
import java.awt.*;

public class FirstApplet extends Applet{
  public void paint(Graphics g){
  g.drawString("Welcome in Java Applet.",40,20);
  }
}

Here is the HTML code of the program:

<HTML>
<HEAD>
</HEAD>
<BODY>
<APPLET
ALIGN="CENTER" CODE="FirstApplet.class" WIDTH="800" HEIGHT="500"></APPLET>
</BODY>
</HTML>

Try online this example.

Download this example.

Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: April 14, 2007

Related Tutorials

Ask Questions?    Discuss: Java Applet - Creating First Applet Example   View All Comments

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments
jitesh
September 3, 2011
applet

no
priti makde
January 3, 2012
hello

java is intrestng language
turki
January 9, 2012
java applet

I need more examaple about applet ,servlet and JSP servlet
Neha khandelwal
March 13, 2012
Java Applet

i want question for different applet creating
Jitendra
August 26, 2012
Advanced JAVA

Explain java
Sharad Jakhad
October 11, 2012
thanks

Thanks for the help me in running applet becouse I am innocent about applet while I am a programmer of c.
DMCA.com