A case of bad cropping
Recently, by pure chance, I've been working for two different research projects which both have involved Java Applets.
The first project ran afoul of bug #6669818 which prevented the applet from connecting back to the originating server during LiveConnect calls, in Mozilla Firefox on a Windows XP platform.
Fortunately there is a workaround for this; by passing the task off to another thread which was started in a non-LiveConnect part of the Applet's lifecycle, the task is then executed in another thread which is not subject to the same malfunctioning security check.
If you'd rather not have to create a thread just for this, a quick hack is to pass the event off to the applet rendering thread using the SwingUtilities.invokeLater(Runnable); function.
In the second project I've now encountered another platform-specific Applet quirk, this time with Mac OSX.
Using Javascript it is possible to change the size of an Applet on the page in the same way you would any other DOM element, however on Mac OSX any browser using the Java Embedding Plugin (Firefox, Opera and others) will fail to resize Java Applets correctly.
I've knocked up a simple test page which allows this to be tested, and shows a potential workaround.
There appear to be two problems cropping up; the first is that the Browser does not notify the Applet that it ought to resize. If you leave the "Notify Java" check-box un-checked when submitting the form, the browser expands the area the Applet ought to be using, but the applet continues to draw in it's original position.
The second issue is that when axis are changed and Java is manually notified the behaviour still does not perform as it ought to. The clipping region of the Java applet rendering is not updated correctly, and thus only part of the applet is correctly rendered.
There is a temperamental workaround for this, by programatically resizing one axis and then the other in quick succession, but this seems to fail as often as it works, depending on whether the page is being loaded from nothing, refreshed, no-cache refreshed or returned to via the browser 'Back' action.
In the interest of getting this bug fixed the code to the Applet resize test page is linked from the test page and free for all to use.
Bugs:
Labels: java, javascript, programming, web
