Advanced Java Tutorial

Total available pages count: 55
Subject - Java Technologies

Applet class

Java, applet.Applet class provides the extension for every applet. The main applet class has a method that can be derived from the applet class called to obtain the data & the services from the web browser context.


The method includes,

  • To get the applet parameter
  • To get the network location of the HTML file that contains the applet.
  • To get the network location of the applet class directory
  • Have to fetch the audio clip in the applet
  • To play an audio clip on the applet
  • To fetch the image

Invoking applet

Applet can be invoked by embedding directive in HTML file & displaying the file through applet viewer.

The <applet> tab has a basis for embedding applet in HTML file. Let understand  using the below example to invoke the “MyApplet” applet.

<title>The Hello, world Applet</title>
<applet code = "MyApplet.class" width = "320" height = "120">
	If your browser was java-enabled,  "Hello, world"
	message would appear here.


The code attribute of  <applet> tag is used. It uses to run the apple class. the width & height are also required to mention the initial size of the panel in which the applet can run.  The applet directive should be closed with the </applet> tag.

If applet takes the parameter, values that might be passed for the parameter by add <param> tag between the  <applet> tags. The browser ignores the tags in between the applet tags.

Java must be enabled in the browser to run the applet. so a non-java-enabled browser can not process the applets.


Applets have a list of event handling methods from the container class. the container class can have several methods i.e. processKeyEvent & ProcessMouseEvent to handle a particular type of the event & one catch all the method call the processEvent.

In order to respond event, the applet should be overriding the appropriate event-specific method.