Here is the basic premise:
I have a class Temp that extends a class Election that extends JApplet.
What I want to do is make use of JApplets getAppletContext().showDocument
functionality, so that I can open a URL in the webrowser that Election
resides in. However, when I attempt to implement this, I get a
NullPointerException indicating that no value exists for getAppletContext().
Here is the relevant code:
class TempResult extends Election{
String url;
public TempResult(String url) {
this.url = url;
}
public void displayResult() {
try {
super.getAppletContext().showDocument(new URL(this.url), "_blank");
}
catch (Exception e) {
JOptionPane.showMessageDialog(null, e);
}
}
}
Any thoughts? Your help is appreciated!
Andrew Thompson - 03 Dec 2003 11:38 GMT
> Here is the basic premise:
>
> I have a class Temp that extends a class Election that extends JApplet.
...
> Here is the relevant code:
No, that was actually a code snippet, which
may or may not indicate the problem.
Could you strip your code to the shortest self-contained
compileable code that displays the problem and post
(all of) it?
BTW - are you running this in 'AppletViewer' at the
moment? What is your browser, browser version
and OS?
--
Andrew Thompson
* http://www.PhySci.org/ PhySci software suite
* http://www.1point1C.org/ 1.1C - Superluminal!
* http://www.AThompson.info/andrew/ personal site
Christian Kaufhold - 03 Dec 2003 14:33 GMT
> I have a class Temp that extends a class Election that extends JApplet.
> What I want to do is make use of JApplets getAppletContext().showDocument
> functionality, so that I can open a URL in the webrowser that Election
> resides in. However, when I attempt to implement this, I get a
> NullPointerException indicating that no value exists for getAppletContext().
Just because something is a subclass of Applet does not make it magically
get an applet context.
Christian

Signature
And in short, I was afraid.