Win a copy of JDBC Workbook this week in the JDBC and Relational Databases forum
or A Day in Code in the A Day in Code forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
  • Piet Souris
  • salvin francis
  • fred rosenberger

Applet from another Applet

Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is there any one who can help me in finding out how an Applet is called from another Applet. I need to call the second applet when an event is generated from the 1st applet ( e.g. on click of a button). Find attached the code I wrote for the 1st applet
import java.awt.*;
import java.applet.*;
/* <APPLET CODE=AWTEventDemo.class WIDTH=500 HEIGHT=500></APPLET>*/
public class AWTEvent extends Applet
TextField t1;
TextField t2;
Button b1;
// Default constructor
public AWTEvent()
// Call superclass
t1=new TextField("1");
t1.reshape(10, 40, 80, 25);
t2=new TextField("2");
t2.reshape(10, 80, 70, 30);
b1=new Button("Button1");
b1.reshape(10, 120, 70, 30);

// Init method, called when applet first initialises
public void init()
setBackground( Color.gray );
public boolean action (Event evt, Object what)
// Was the focus of the event our button
if ( == b1)
//this is where I need the new applet to be opened up, can any body give me a helping hand
// Clear the textfield
// Event handled
return true;
return false;

// Overridden paint method
public void paint ( Graphics g )
g.setColor ( );

Thanks in advance
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To call your second applet from the first, all you have to do is call another web page that contains your second applet.
in your eventHandle(ActionPerformed)
(new URL("";),"_self");
catch (Exception ex) {System.out.println(ex}
Posts: 7023
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The third item listed on Tony Alicea's web page is an example of inter-Applet communication.
Devu Nair
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Philip Pross and Dirk Schreckmann, It worked.
Thanks a lot for your help.
No thanks. We have all the government we need. This tiny ad would like you to leave now:
Devious Experiments for a Truly Passive Greenhouse!
    Bookmark Topic Watch Topic
  • New Topic