[3395] in java-interest
Netscape 2.0b2/Java Interface: AppletContext.showDocument
daemon@ATHENA.MIT.EDU (Magda Nour)
Fri Nov 10 03:23:37 1995
Date: Thu, 9 Nov 1995 22:39:33 +0500
From: magda@hobbes.hr.att.com (Magda Nour)
To: java-interest@java.sun.com
I'm having a problem with an applet which tries to get
its AppletContext and run showDocument.
I reduced the applet as much as possible (the applet code
follows the error description).
First some background: I'm running on a Sun Sparc 10
under Solaris 2.3, using the Beta JDK (not pre-release)
and Netscape Version 2.0b2.
This runs fine the first time. I press the button and
the Netscape window which contains the applet goes to
my home directory.
However, the next time I use the applet, whether it be
on the same page (by going back) or even if I reload it
on the top of the Netscape URL stack or even if I start a new
Netscape browser window (same executable), it doesn't work.
Basically, I must restart Netscape to have it work again.
When it fails I get a java.lang.NullPointerException
with the following stack trace:
at netscape.applet.MozillaAppletContext.showDocument0(MozillaAppletContext.java:125)
at netscape.applet.MozillaAppletContext.showDocument(MozillaAppletContext.java:117)
at GoHomeButton.action(GoHomeButton.java:25)
at java.awt.Component.handleEvent(Component.java:886)
at java.awt.Component.postEvent(Component.java:832)
at java.awt.Component.postEvent(Component.java:838)
at sun.awt.motif.MButtonPeer.action(MButtonPeer.java:39)
at java.lang.Thread.run(Thread.java:286)
Unfortunately, I don't have access to the MozillaAppletContext.java file
(does anyone know where I can find that?).
I thought that perhaps the applet was not being destroyed properly
since the page was changing in GoHomeButton.action() so I tried
to put the showDocument() call in GoHomeButton.destroy(), but I got
pretty much the same behavior (slightly different stack trace, of course).
The following is the applet code:
----------------------------------------------------
import java.awt.*;
import java.io.*;
import java.applet.*;
import java.net.*;
public class GoHomeButton extends Applet {
Panel topPanel;
public void init()
{
topPanel = new Panel();
add("Center", new Button("Go Home"));
}
public boolean action(Event evt, Object what)
{
URL home;
AppletContext appletContext;
if (what.toString().compareTo("Go Home") == 0)
{
appletContext = getAppletContext();
try {
home = new URL("http://dundee.hr.att.com/~magda/mylinks.html");
appletContext.showDocument(home);
} catch (MalformedURLException e) {
System.out.println("EntityWindow: action(), malformed URL");
} catch (IOException e) {
System.out.println("EntityWindow: action(), io exception");
} catch (Exception e) {
System.out.println("EntityWindow: action(), other exception: " + e.toString());
e.printStackTrace();
}
}
return true;
}
}
----------------------------------------------------
I would appreciate any insight or help anyone could give me.
Thanks.
Magda Nour
magda@corona.att.com
(908) 615-5149
-
This message was sent to the java-interest mailing list
Info: send 'help' to java-interest-request@java.sun.com