Problem solve Get help with specific problems with your technologies, process and projects.

What is a Java Applet?

I still don't understand what a Java Applet is and what it's used for? Would you explain a bit more in layman's...

terms? A Java applet is a Java application built to execute within the Java applet framework. The applet framework provides a very restricted "sandbox" in which the applet will run. The framework restricts such things as writing to the user's file-system, accessing servers outside of the applets context, etc. The applet framework mandates that the applet implement a few coarse-grained, lifecycle, callback methods (init, start, stop, and destroy) in order for the applet to perform in a well-behaved manner when running in a Web browser.

Here is an example of a simple applet:

import java.applet.*;
import java.awt.*;
public class HelloWorldApplet extends Applet
   public void init()
      // Called once when the applet is created.
   public void start()
      // Called whenever the applet's container (browser page)
      // gains the focus.
   public void stop()
      // Called whenever the applet's container (browser page)
      // loses the focus.
   public void destroy()
      // Called once just prior to the applet being destroyed.
   public void paint(Graphics g)
      // Called whenever the applet needs to repaint.
      g.drawString("Hello world!", 4, 50);

This was last published in October 2004

Dig Deeper on Microservices pattern, platforms and frameworks

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Please create a username to comment.