Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem in using JSObject.getWindow() mehod

 
Priyatam
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guru's
I am facing a small problem in using JSObject.getWindow() method for communication b.w Applet to browser.
I have a link eg..XXX in one webpage, cliking that link will open another brower window in which my applet runs. In the applet I have one button if I click the button the browser window in which the applet running should close. I am attaching a sample piece of code. The below code works fine for the first time. If I click on the link XXX next time the applet is not loading.
I debugged it the problem is coming at JSObject.getWindow() method. could anybody show me a solution to this problem?
I hope u understood the problem :-)
waiting for ur reply
Thanks
Priyatam
import netscape.javascript.*;
import javax.swing.*;
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class MyApplet extends JApplet implements ActionListener
{
JSObject win = null;
JSObject doc = null;
public void init()
{
JButton jb = new JButton("Close");
jb.addActionListener(this);
this.getContentPane().setLayout(new FlowLayout());
this.getContentPane().add(jb);
}
public void actionPerformed(ActionEvent evt)
{
if(win != null)
{
win.call("closeWindow",null);
}
}
public void start()
{
try
{
if(win == null)
{
win = (JSObject)JSObject.getWindow(this);
}

}
catch(Exception e)
{
System.out.println("Message:"+e.getMessage());
}
}
public void destroy()
{
win = null;
System.out.println("Message: ObjectDestroyed");
}
}

------------------
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic