codescracker


java

Java Applet Basics Tutorial



« Previous Tutorial Next Tutorial »


Java Applet

In Java, an applet is a program that runs in a Web browser. An applet can be a fully functional Java application because it has full Java API at its disposal.

Java Applet Example

The following is a simple applet named HelloWorldApplet.java:

/* Java Program Example - Java Applet Basics */
		
import java.applet.*;
import java.awt.*;

public class HelloWorldApplet extends Applet
{
   public void paint (Graphics g)
   {
   
      g.drawString ("Hello World", 25, 50);
	  
   }
}

Compile and Execute Java Applet Program

This is for BlueJ user. To compile and execute an applet program/application, follow these steps:

java applet

Now provide 200 in height box, and 400 in width box and now click on OK button, and watch the output as shown here.

Here is the output window of the above applet program of 400 width and 200 height.

java applet tutorial

Here are the two import statements in Java, that brings the classes into the scope of our applet class in Java:


« Previous Tutorial Next Tutorial »



Tools
Calculator

Quick Links
Signup - Login - Give Online Test