tag Example in Java
Java Programming

Passing Parameters to Applet(tag)

 

<applet> (<applet code=”app.class” height=500 width=500>)tag is used to pass parameter in an applet. We use <PARAM> tag to pass anapplet parameters. The <PARAM> (<PARAM NAME= firstname VALUE=”REKHA”>)tag has two attributes one is NAME and other is VALUE.

<Param> tag Example in Java

import java.awt.*;

import java.applet.*;

public class app extends Applet

{

                String firstn,lastn,sex,add,city,phone,email;

                Font f1,f2;

                public void init()

                {

                                f1=new Font(“Arial”,Font.PLAIN,16);

                                f2=new Font(“Arial”,Font.BOLD,20);

                }

                public void start()

                {

                                firstn=getParameter(“firstName”);

                                if(firstn==null)

                                firstn=”Not Found”;

                                lastn=getParameter(“lastName”);

                                if(lastn==null)

                                lastn=”Not Found”;

                                sex=getParameter(“sex”);

                                if(sex==null)

                                sex=”Not Found”;

                                add=getParameter(“add”);

                                if(add==null)

                                add=”Not Found”;

                                city=getParameter(“city”);

                                if(city==null)

                                city=”Not Found”;

                                phone=getParameter(“phone”);

                                if(phone==null)

                                phone=”Not Found”;

                                email=getParameter(“email”);

                                if(email==null)

                                email=”Not Found”;

                }

                public void paint(Graphics g)

                {

                                g.setFont(f2);

                                g.drawString(“-:Detail Information about User :- “, 75,20);

                                g.setFont(f1);

                                g.drawString(” First Name of the user:”+firstn,5,60);

                                g.drawString(” Last Name of the user:”+lastn,5,80);

                                g.drawString(“Sex:”+sex,5,100);

                                g.drawString(“Address:”+add,5,120);

                                g.drawString(“City:”+city,5,140);

                                g.drawString(“Contact  no:”+phone,5,160);

                                g.drawString(“Email:”+email,5,180);

                }}

/*<applet code=”app.class” height=500 width=500>

                <PARAM NAME= firstname VALUE=”REKHA”>

                <PARAM NAME= lastname VALUE=”SETIA”>

                <PARAM NAME= sex VALUE=”FEMALE”>

                <PARAM NAME= add VALUE=”A=CIVIL”>

                <PARAM NAME= city VALUE=”PUNJAB”>

                <PARAM NAME= phone VALUE=”9876553500″>

                <PARAM NAME= email VALUE=”rekhasetia2011@gmail.com”>

</applet>

*/

Explanation….

In the above example, the user information is passed as a parameter of the <PARAM> tag. The gerParameter()retrieves the value of each parameter and displays this value on an applet. We can use <PARAM> tag in HTML document. When you are working with the <PARAM>tag, you can change the contents that are displayed on an applet by changing the parameter values in the HTML file. 

PARAM tag example in JAVA Applet

Recommended Posts

C++ Programming

Visibility modes in C++

In C++, visibility modes refer to the accessibility of class members (such as variables and functions) from different parts of a program. C++ provides three visibility modes: public, private, and protected. These modes control the access levels of class members concerning the outside world and derived classes. Public: Members declared as public are accessible from […]

Rekha Setia 
C++ Programming

Inheritance in C++

In C++, inheritance is a fundamental concept of object-oriented programming (OOP) that allows you to create a new class based on an existing class, known as the base or parent class. The new class is called the derived or child class. Inheritance facilitates code reuse and supports the creation of a hierarchy of classes. There […]

Rekha Setia 
C++ Programming

C++ Classes and Objects

In C++, classes and objects are fundamental concepts that support object-oriented programming (OOP). Here’s a brief overview of classes and objects in C++: Classes: In C++, a class is a user-defined data type that allows you to encapsulate data members and member functions into a single unit. Classes are the building blocks of object-oriented programming […]

Rekha Setia 

Leave A Comment