applet

Get an applet parameter

This is an example of how to get an Applet parameter. A Java applet is a special kind of Java program that a browser enabled with Java technology can download from the internet and run. An applet is typically embedded inside a web page and runs in the context of a browser. An applet must be a subclass of the java.applet.Applet class. The Applet class provides the standard interface between the applet and the browser environment. Getting a parameter of an applet implies that you should:

  • Create a class that extends the Applet, such as GetAnAppletParameter class in the example.
  • Use init() API method of Applet. This method is called by the browser or applet viewer to inform this applet that it has been loaded into the system. In this method call getParameter(String name) API method of Applet to get the value of a specified named parameter in the HTML tag.

Let’s take a look at the code snippet that follows:

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
16
17
18
19
20
21
package com.javacodegeeks.snippets.core;
 
import java.applet.Applet;
 
public class GetAnAppletParameter extends Applet {
     
    private static final long serialVersionUID = -4164165523218431494L;
 
    // Called by the browser or applet viewer to inform
    // this applet that it has been loaded into the system.
    public void init() {
         
        String parameter1 = "param1";
        String value1 = getParameter(parameter1);
 
        String parameter2 = "param2";
        String value2 = getParameter(parameter2);
         
    }
 
}
1
2
3
4
5
<applet code="com.javacodegeeks.snippets.core.GetAnAppletParameter"
        width="200" height="200'>
    <param name="param1" value="first param">
    <param name="param2" value="second param">
</applet>

 
This was an example of how to get an Applet parameter in Java.

Do you want to know how to develop your skillset to become a Java Rockstar?
Subscribe to our newsletter to start Rocking right now!
To get you started we give you our best selling eBooks for FREE!
1. JPA Mini Book
2. JVM Troubleshooting Guide
3. JUnit Tutorial for Unit Testing
4. Java Annotations Tutorial
5. Java Interview Questions
6. Spring Interview Questions
7. Android UI Design
and many more ....
I agree to the Terms and Privacy Policy

Byron Kiourtzoglou

Byron is a master software engineer working in the IT and Telecom domains. He is an applications developer in a wide variety of applications/services. He is currently acting as the team leader and technical architect for a proprietary service creation and integration platform for both the IT and Telecom industries in addition to a in-house big data real-time analytics solution. He is always fascinated by SOA, middleware services and mobile development. Byron is co-founder and Executive Editor at Java Code Geeks.
Subscribe
Notify of
guest


This site uses Akismet to reduce spam. Learn how your comment data is processed.

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
Back to top button