aspose file tools*
The moose likes Applets and the fly likes Applet -Applet communication prb Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » Applets
Bookmark "Applet -Applet communication prb" Watch "Applet -Applet communication prb" New topic
Author

Applet -Applet communication prb

Rajeev Kashyap
Greenhorn

Joined: Sep 07, 2004
Posts: 19
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
Maybach Smith
Greenhorn

Joined: Dec 22, 2004
Posts: 15
Hai,

Hope this is useful to you.
http://www.javaworld.com/javaworld/javatips/jw-javatip101.html


Maybach
Rajeev Kashyap
Greenhorn

Joined: Sep 07, 2004
Posts: 19
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Applet -Applet communication prb
 
Similar Threads
CALLING RAUKAUTAM SANDEEP,ANGELA
Please help me for Applet Communications!
jsp:plugin with Mozilla
Applet from another Applet
applet-servlet communication