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

Applet platform issues

1 view
Skip to first unread message

Muffet

unread,
Jan 4, 2003, 1:06:27 AM1/4/03
to
I wrote an applet using jdk1.1.8 so it can be run by as many platforms
as possible. I'm not sure how java is configured on those browsers,
but a user found the following problems. Any ideas or help would be
greatly appreciated.

1. Win2000/Netscape 7: instead of the applet, an icon is displayed to
install jre140_01i.xpi. After clicking the link, a message states
that Java 2 already exists on this machine, so do you want to
uninstall or cancel? Despite choosing either option, the browser tries
to install the xpi again without any success.

2. Unix/Netscape 4.79: the applet doesn't even appear.

3. Mac OS9/ IExplorer 5: applet loads upon the first visit to the
webpage. Multiple returns to the webpage will throw this exception:

java.lang.NullPointerException
at sun.awt.SunToolkit.getImageFromHash(SunToolkit.java)
at sun.awt.SunToolkit.getImage(SunToolkit.java)
at MapApplet$MapPane.<init>(MapApplet.java:204)
at MapApplet.init(Compiled Code)

I think it's because it has problems reloading an image from the
applet jarfile, in the lines below? Would changing the url to a web
address fix it?

URL url = MapApplet.class.getResource("img.gif");
image = Toolkit.getDefaultToolkit().getImage(url);

Muffet

unread,
Jan 4, 2003, 11:08:24 AM1/4/03
to

Peter Jones

unread,
Jan 5, 2003, 10:51:15 AM1/5/03
to

I had problems reading an image from the JAR file and found this
workaround. I only needed it for small images (10K or less), so you
may have to make small changes:

InputStream is =
getClass().getResourceAsStream(imgName);
BufferedInputStream bis = new
BufferedInputStream(is);
byte[] byBuf = new byte[10000]; // a buffer
large enough for our image
//
// can be
// byte[]
byBuf = = new byte[is.available()];
//
is.read(byBuf); or something like that...
//
int byteRead = bis.read(byBuf,0,10000);
img =
Toolkit.getDefaultToolkit().createImage(byBuf);

Peter
Digital Photography Reference
http://members.shaw.ca/jonespm2/PJDigPhot.htm
Touchup, an image processing applet
http://members.shaw.ca/jonespm2/software.htm
Health, happiness and healing
http://www.SuperNaturalWoman.com

Ike

unread,
Jan 6, 2003, 7:08:22 PM1/6/03
to
public Image toImageFromFile(String f){
Toolkit tk = Toolkit.getDefaultToolkit();
URL url = getClass().getResource(f);
Image image = tk.getImage(url);
MediaTracker tracker = new MediaTracker(this);
tracker.addImage(image, 0);
try { tracker.waitForID(0); }
catch (InterruptedException exception) {}
return image;
}


0 new messages