Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-1239473

fp.bugs 3733 Appletviewer NullPointerExeption in getAppletContext from init

    XMLWordPrintable

    Details

    • Subcomponent:
    • CPU:
      sparc
    • OS:
      solaris_2.5

      Description


      >From: Pria Graves <###@###.###>
      This does not look like form output to me.


      I have encountered something I believe to be a bug (or at least a
      documentation problem). I am running Solaris 2.4 (redirected to a SunOS
      machine), doing development with the JDK downloaded on January
      25th. The problem occurs ONLY when running with the java interpreter.
      I am not experiencing this problem when running with either Netscape
      2.0 or the appletviewer.

      The problem comes when I attempt to do a getImage to retrieve an
      icon. It appears that the getImage method calls getAppletContext,
      which returns a null pointer. Here's the messages:

      java.lang.NullPointerException
              at java.applet.Applet.getAppletContext(Applet.java:83)
              at java.applet.Applet.getImage(Applet.java:120)
              at Demo.init(Demo.java:27)
              at Demo.main(Demo.java:14)

      Here's the code. Is there something I'm missing? It makes no
      difference whether the url is in file or http format...



      // Applet : Demo
      import java.awt.*;
      import java.lang.*;
      import java.applet.*;
      import java.net.*;

      public class Demo extends Applet implements Runnable
      {
          private Image img = null;
          public static void main(String args[])
          {
      Frame frame = new Frame("Health Monitor Lite");
      Demo demo = new Demo();
      demo.init();
      frame.add("Center", demo);
      frame.show();
          }

          public void init()
          {
      super.init();
      URL url = null;
      try {
      url = new URL("file:/users/priag/java/gauge/images/2500.xbm");
      }
      catch(MalformedURLException e);
      img = getImage(url);
          }

          public void run()
          {
      System.out.println( " you are running");
          }
      }


      Thanks,

      Pria

        Attachments

          Activity

            People

            Assignee:
            egilbertsunw Eric Gilbertson (Inactive)
            Reporter:
            bhagen Benjamin Hagen (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: