Hi to all,
I have following two Applets .

import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class buttonDemo extends Applet implements ActionListener
{
String msg="";
Button one,two,three;
public void init()
{
one=new Button("One");
two=new Button("Two");
three=new Button("Three");
add(one);
add(two);
add(three);
one.addActionListener(this);
two.addActionListener(this);
three.addActionListener(this);
}
public void actionPerformed(ActionEvent ae)
{
String str=ae.getActionCommand();
if(str.equals("One"))
{
msg="You pressed one";
}
else
if(str.equals("Two"))
{
msg="You pressed two";
}
else
{
msg="You pressed three";
}
repaint();
}
public void paint(Graphics g)
{
g.drawString(msg,10,20);
}    
}

And

import java.awt.*;
import java.applet.*;
public class appletDemo extends Applet
{
String msg;
public void init()
{
appletDemo a= new appletDemo();
a.setSize(500,100);
setBackground(Color.pink);
msg="A simple applet";
}
public void paint(Graphics g)
{
g.drawString(msg,10,20);
}
}

I wand to call second Applet window from the "One" button in first Applet.
I don't have any idea about calling one Applet from another Applet' button.

Please give me hint about it.

Thanks.

Hi,

I agree with Ewald, but if you search a simple solution (if there is no message to passe from the first applet to the second) you can make a simple redirection to the html page wich contains the second applet. In this solution, you will have two web pages, each page contains one applet. To realize the redirection, you can use :

getAppletContext().showDocument()

A simple example is given here :

Click Here

Good Luck

Comments
Nice idea.
This article has been dead for over six months. Start a new discussion instead.