Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / GUI / December 2003

Tip: Looking for answers? Try searching our database.

A question about getAppletContext()

Thread view: 
Mike - 02 Dec 2003 23:34 GMT
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.



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.