applet

Get an applet parameter

Photo of Byron KiourtzoglouByron KiourtzoglouNovember 11th, 2012Last Updated: October 21st, 2013
0 79 1 minute read

This is an example of how to get anApplet 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 thejava.applet.Applet class. TheApplet 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 theApplet, such asGetAnAppletParameter class in the example.
  • Useinit() 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 callgetParameter(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:

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);        }}
<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 aJava Rockstar?
Subscribe to our newsletter to start Rockingright now!
To get you started we give you our best selling eBooks forFREE!
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 theTerms andPrivacy Policy

Thank you!

We will contact you soon.

Photo of Byron KiourtzoglouByron KiourtzoglouNovember 11th, 2012Last Updated: October 21st, 2013
0 79 1 minute read
Photo of Byron Kiourtzoglou

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 atJava Code Geeks.

Related Articles

Bipartite Graph

Play audio in Applet

November 11th, 2012
Bipartite Graph

Draw Image in Applet

November 11th, 2012
Bipartite Graph

Applet lifecycle methods

November 11th, 2012
Subscribe
Notify of
guest
I agree to theTerms andPrivacy Policy
The comment form collects your name, email and content to allow us keep track of the comments placed on the website. Please read and accept our website Terms and Privacy Policy to post a comment.

I agree to theTerms andPrivacy Policy
The comment form collects your name, email and content to allow us keep track of the comments placed on the website. Please read and accept our website Terms and Privacy Policy to post a comment.