beingtopper.jkp@gmail.com
+91-8700702530
Free Demo

Being Topper

  • About Us
  • Knowledge Base
  • Modules
  • Branches
    • Ajmer
    • Tilak Nagar
    • Noida
    • Chandigarh
    • Mumbai
  • Contact Us

Being Topper

  • About Us
  • Knowledge Base
  • Modules
  • Branches
    • Ajmer
    • Tilak Nagar
    • Noida
    • Chandigarh
    • Mumbai
  • Contact Us
  • About Us
  • Knowledge Base
  • Modules
  • Branches
    • Ajmer
    • Tilak Nagar
    • Noida
    • Chandigarh
    • Mumbai
  • Contact Us

Being Topper

  • About Us
  • Knowledge Base
  • Modules
  • Branches
    • Ajmer
    • Tilak Nagar
    • Noida
    • Chandigarh
    • Mumbai
  • Contact Us
AppletB.tech notesBCA NOTESInformation technologyJava ProgramsPrograms/Algorithm

Example of an applet program in java

Being Topper 18/02/2014 0 Comments

Introduction to An Applet program in Java

Before Jumping Straight to Writing an Applet program in java lets us first introduce applet. Applet is a special type of program which is embedded in a webpage to generate the dynamic content. An Applet runs inside the browser and works at client side.

 

Advantages of Applet

Here are the advantages of applet in Java :

–> It works at client side so give response in less time.
–> Its secured
–> It can be executed by browsers running under various platforms, including Linux, Windows, Mac Os etc.

Disadvantages of Applet in Java

Plugin required at client side browser to run applet.

 

Example of an applet program in java

This program is based on the inter applet communication. In this program , we are selecting the color of the second applet from the first applet

import java.applet.*;
import java.awt.*;
import java.awt.event.*;
/*
<applet code="FirstApplet" height ="400" width = "200" name="first">
</applet>
<applet code="SecondApplet" height ="400" width = "200" name="second">
</applet>
*/
public class FirstApplet extends Applet implements ActionListener
{

Button b1,b2 ;
public void init()
{
b1 = new Button("red");
b2 = new Button("green");
b1.addActionListener(this);
b2.addActionListener(this);

add(b1);
add(b2);
setBackground(Color.gray);

}

public void paint (Graphics g)
{
g.drawString ("select the colour", 30,50);
g.drawString ("for second applet", 30,70);

}
public void actionPerformed (ActionEvent e)
{

AppletContext ctx = getAppletContext();
SecondApplet sa = (SecondApplet) ctx. getApplet("second");// downcasting is done here .....
if (e.getSource() == b1 )
{
sa.setBackground(Color.red);

}
if(e.getSource()== b2 )
{
sa.setBackground(Color.green);
}

}
}
Example of an applet program
AboutBeing Topper
In Socials:
PrevWrite a C program to generate Pascal's triangle18/02/2014
Java Program for working Pacman game18/02/2014Next

Related Posts

BCA NOTESVB.Net progrmas

VBScript Full Program for structure | Structure in VBScript

Before Writing a program for structure in VBScript we have to know what is a structure...

Being Topper 18/01/2014
BCA NOTESVB.Net progrmas

WAP to demonstrate Polymorphism in Vb.net through Method Overloading

 Demonstratation of  Polymorphism in Vb.net through Method Overloading : code begins...

Being Topper 17/10/2014
Categories
Recent Posts
  • Best Email Marketing Software and Services
  • How to Apply Adsense on YouTube
  • Complete Guide to Writing a Newsletter !
  • Benefits of Creating Email List for small Businesses | Digital Marketing
  • Create Account or Get Email Alerts When New Employees Join a Company

Copyright © 2021 Being Topper ® . All Rights Reserved