Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

starting one applet from another applet

Status
Not open for further replies.

daka94

Programmer
Apr 27, 2001
33
US
Dear friend
i want to start one applet from another applet.
how can i do this .
help me
thank you in advance
 
Hi,

All you have to do is just to create an instance of the new applet and call the init() method of the new applet. Example:-

import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class test extends Applet implements ActionListener
{
public void init()
{
setSize(200,200);
setLayout(null);

Button b = new Button("Click");
b.setBounds(new Rectangle(10,10,50,20));
b.addActionListener(this);

add(b, null);
}
public void actionPerformed(ActionEvent e)
{

test2 t = new test2();
t.setBounds(new Rectangle(10,110,190,90));
t.init();
add(t,null);
}
}

class test2 extends Applet
{
public void init()
{
setSize(100,100);
setLayout(null);

Button b = new Button("Click2");
b.setBounds(new Rectangle(0,10,50,20));
add(b, null);
}
} If you need additional help, you can email to me at zaoliang@hotmail.com I don't guaranty that I will be able to solve your problems but I will try my best :)
 
Hi,

All you have to do is just to create an instance of the new applet and call the init() method of the new applet. Example:-

import java.applet.*;
import java.awt.*;
import java.awt.event.*;

public class test extends Applet implements ActionListener
{
public void init()
{
setSize(200,200);
setLayout(null);

Button b = new Button("Click");
b.setBounds(new Rectangle(10,10,50,20));
b.addActionListener(this);

add(b, null);
}
public void actionPerformed(ActionEvent e)
{

test2 t = new test2();
t.setBounds(new Rectangle(10,110,190,90));
t.init();
add(t,null);
}
}

class test2 extends Applet
{
public void init()
{
setSize(100,100);
setLayout(null);

Button b = new Button("Click2");
b.setBounds(new Rectangle(0,10,50,20));
add(b, null);
}
}

Regards,
Leon If you need additional help, you can email to me at zaoliang@hotmail.com I don't guaranty that I will be able to solve your problems but I will try my best :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top