I have an applet in which i want to load 2 images, one from my hard-disk and one from an url adress. The applet is loading both of the images, the problem is that is taking too long to load the images (more than 10 sec). The applet is blank untill the url images is loaded, and this is taking too long. If i click run file from the IDE to see the Applet Viewer it's working fine, both images are are loaded very quick. The problem is only when i want to see the applet in the browser. I added the applet in an HTML file with the applet tag.
My applet is extending the JApplet class.
Thank you, and Happy NEW YEAR !
I'm having the same issue, in a more general aspect as it spreads out all over the applet logic.
Not only loading from a single URL is VERY slow inside a browser, it freezes when having concurrent access to an URL (even using threads).
The "getImage" method is supposed to be asynchronous, yet when calling it multiple times it unexpectedly freezes.
I can see the parallel between our two issues Florin and although a solution surely exists, it's been very random to find anything related on the web.
Hope somehow could enlighten us both on that.
Thank you all!
Joined: Dec 30, 2009
Seems like the issue is not 'Image' related but more like 'URL' related.
When loading a single Image from an URL, the applet does not freeze. Sure, it's still extremely slow from what i'd expect, but the applet logic runs without worrying about the image being loaded.
However, when trying to access a second URL the applet does freeze.
Florin, how about loading one image? Is it still slow? Is your applet still blank?
My applet is slowing when loading URL images, even if i try to load only 1 image.
I tried also to use MediaTracker, but unfortunately the behaviour is the same.
My question is, why when i run the file in the applet viewer it's working fine, but in my browser it's running so slow?
Joined: Dec 30, 2009
It looks like you are on the right track.
I've been thinking and it seems that the only difference between running an applet in the applet viewer and in a browser lies in the policy file.
Be it my issue, which I first thought was what Florin experienced, or his, although they are somehow related, it is explained by the applet viewer allowing every security rule, well, as far as I understand it.
Would the solution be signing the applet and authorizing a magic what's-its-name security rule?
Hope not, I don't feel like paying to get a certificate from a CA...
EDIT: I modified my policy file and it works like a charm!
It's not slow anymore and concurrent access does not block the applet either.
This lad has it working without signing the applet, I'm still trying to figure out why.
Nonetheless, it's pretty strange that nobody ever ran into this problem, loading (multiple) image(s) from somewhere is something pretty common in RIAs.
Oh, and shouldn't be accessing resources (like images) from a different domain not authorized by default applet policies?
The more you dig in this, the more you get confused, eh. ; )
EDIT: nevermind the above comment, found later that crossdomain.xml do the trick since Java update 10