Re: Problem with MediaTracker
Giox wrote:
...
The code that I propose at the end of the post should read an image
and display it in an applet, refreshing it each time it is loaded.
No. That code was a waste of bandwidth.
After fixing the wrapped line and changing the hard coded
image name (had you ever heard of the applet param element?),
I realised that it was missing an init() or a paint(), and called
none of the methods of interest.
After overriding paint to draw the image, and adding an init() to
create the MediaTracker, and kick off that horrendous loop..
I forgot what the question was.
Oh yeah - 'image caching'. Yeah (shrugs) The Java Plug-In
is terribly 'cachey' of images. I am more surprised that your
code worked in earlier (or any, for that matter) VMs, than
that it breaks now.
There are a number of ways to get around the image caching,
the most reliable way is to load the image as bytes, then use
the Toolikt.createImage(byte[]) method to stamp it out to a
usable graphic.
A few other comments.
I set up a policy file where the applet is compiled using
grant {
permission java.security.AllPermission;
};
What on earth possessed you to do that? This
applet requires no extended permissions.
...
I think that the code lines
tracker.removeImage(myImage);
myImage.flush();
should work correctly but it seems that Java 1.6 changed the meaning
of these instructions, when executed in a web browser.
If you can get the behaviour you want in the AppletViewer,
you can get the same effect by launching the applet
using Java web start. JWS uses the applet viewer.
In the next rows I propose a section of the applet.
'sections' of applets are usually no good. Please consider
posting SSCCE code that others can work with, without
having to try and 'guess' what was in the other 'missing' parts
of the code.
<http://www.physci.org/codes/sscce.html>
--
Andrew Thompson
http://www.physci.org/
Message posted via JavaKB.com
http://www.javakb.com/Uwe/Forums.aspx/java-general/200712/1