Forum Stats

  • 3,828,061 Users
  • 2,260,856 Discussions
  • 7,897,443 Comments

Discussions

cast error only when using JNLP

800485
800485 Member Posts: 66
edited Jan 19, 2011 2:51AM in Java Web Start & JNLP
Hi

I have written a draggable applet and it raises an unexpected cast error in particular conditions. When using the APPLET tag there is no problem, but when using a JNLP file and dragging twice the applet outside the browser, the restore method fails.

here is the restore method :

public void appletRestored() {
try {
Enumeration e = getAppletContext().getApplets();
while(e.hasMoreElements()) {
BuggedApplet theapplet = (BuggedApplet)e.nextElement();
}
}
catch (Exception e) {
e.printStackTrace();
}
}

the exception is :

java.lang.ClassCastException: BuggedApplet cannot be cast to BuggedApplet
at BuggedApplet.appletRestored(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.plugin2.applet.DragHelper$PerAppletInfo.sendAppletRestored(Unknown Source)
at sun.plugin2.applet.DragHelper$PerAppletInfo.restore(Unknown Source)
at sun.plugin2.applet.DragHelper.restore(Unknown Source)
at sun.plugin2.main.client.PluginMain$PluginMainDragListener.appletExternalWindowClosed(Unknown Source)
at sun.plugin2.applet.DragHelper$PerAppletInfo$CloseListener.actionPerformed(Unknown Source)
at sun.plugin2.applet.DragHelper$PerAppletInfo$6.mouseClicked(Unknown Source)
at java.awt.Component.processMouseEvent(Unknown Source)
at java.awt.Component.processEvent(Unknown Source)
at java.awt.Component.dispatchEventImpl(Unknown Source)
at java.awt.Component.dispatchEvent(Unknown Source)
at java.awt.EventQueue.dispatchEvent(Unknown Source)
at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
at java.awt.EventDispatchThread.run(Unknown Source)

how to reproduce :
load this page in browser : http://r35506.ovh.net/bug/splash.html
drag the applet outside the browser
reload the page
drag the applet outside the browser (you now have 2 applets dragged)
close the 2nd applet, it raises the exception

there is no problem when not using JNLP, you can check it at :
http://r35506.ovh.net/bug/index.html

Edited by: user1114974 on 18 janv. 2011 23:41
Tagged:
This discussion has been closed.