• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Applet -Applet communication prb

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I want to call a method of one applet(AppA) in another applet(AppB)but on Java Console it is giving null pointer exception. Following is code.

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

public class AppA extends Applet
{
Button b1;

public void init()
{
b1=new Button("A");
add(b1);
}

public String say()
{
return "hello";
}
}

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

public class AppB extends Applet implements ActionListener
{
Button b1;
TextField t1;

public void init()
{
b1=new Button("Click");
b1.addActionListener(this);
t1=new TextField(10);
add(b1);
add(t1);
}

public void actionPerformed(ActionEvent e)
{
AppA r=(AppA)getAppletContext().getApplet("AppA");
t1.setText(r.say());
}
}

<html>
<body>
Applet Comm Ex
<applet code="AppA" width="400" height="100" name="app1"> </applet>
<hr width=2>
<br>
<applet code="AppB" width="400" height="100" name="app2"> </applet>
<br>
</body>
</html>

Please let me know solution
 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hai,

Hope this is useful to you.
http://www.javaworld.com/javaworld/javatips/jw-javatip101.html
 
Rajeev Kashyap
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem was wrongly described by me.
The actual problem is suppose in web page there is frame containing two html pages say htmA.html and htmB.html. In htmA.html there is one applet say AppletA and in htmB.html there are two applets say AppletB and AppletC.
Now invoking the method of AppletA is not possible through AppletB but any method method of AppletC can be invoked through AppletB.

Is the AppletContext is limited to single html web page or for whole web page? If the appletcontext is limited to html page then what is the solution to invoke applet's method of other html page in same web page.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic