Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Applet-subclass-image-handle-problem

1 view
Skip to first unread message

Benjamin Hössl

unread,
Apr 30, 2002, 5:42:08 PM4/30/02
to
Hi NG,
I have a problem with the Toolkit.getDefaultToolkit().getImage(String, int)
method. In the normal Applet viewer there is no problem with getting
pictures with this method, but when I try to run in a browser e.g. Internet
Explorer or Netscape, i get security probs. I'm using this method in a
subclass.
However the problem can be worked around by using
applet.getImage(getCodeBase(),String) but there is my problem. To be able to
use this method, my class must extend Applet as far as I can see. But when I
let my subclass extend Applet plus my mainclass extends Applet I'm not
getting any pictures but NullPointerExceptions.

---snip---
C:\jdk1.2.2\bin\appletviewer.exe Experiment.html
Working Directory - c:\Documents and Settings\Benjamin\My
Documents\Code\Java\Internet-Experiment\
Class Path -
.;c:\Kawapro5.0\kawaclasses.zip;c:\jdk1.2.2\lib\tools.jar;c:\jdk1.2.2\jre\li
b\rt.jar;c:\jdk1.2.2\jre\lib\i18n.jar
java.lang.NullPointerException: at
java.applet.Applet.getCodeBase(Applet.java:94) at
ImageStim.putImage(ImageStim.java:22) at Experiment.init(Experiment.java:12)
at sun.applet.AppletPanel.run(AppletPanel.java:343) at
java.lang.Thread.run(Thread.java:472) Process Exit...
---snap---

My Question: Is there any possibility to use a secure method to get Images
into an array in a subclass?

Thanks for your help
Benjamin


0 new messages