Skip to main content

OS X 10.8 Java 7 applet exception on dragStart

5 replies [Last post]
bjoreman
Offline
Joined: 2009-02-15
Points: 0

Does anyone recognize a problem like this? It seems to be quite some way outside our own code, but you never know. Someone might have a workaround, or be able to suggest just who to report this to if it is indeed a bug :-) …

In short, we get an exception when trying to start a drag when our Swing application is run as an applet inside a browser window. Releasing the applet from the window (dragging it out) makes things work.

***java.lang.ClassCastException: sun.lwawt.macosx.CPlatformEmbeddedFrame cannot be cast to sun.lwawt.macosx.CPlatformWindow
java.lang.ClassCastException: sun.lwawt.macosx.CPlatformEmbeddedFrame cannot be cast to sun.lwawt.macosx.CPlatformWindow
at sun.lwawt.macosx.CDragSourceContextPeer.startDrag(CDragSourceContextPeer.java:124)
at sun.awt.dnd.SunDragSourceContextPeer.startDrag(SunDragSourceContextPeer.java:134)
at sun.lwawt.macosx.CDragSourceContextPeer.startDrag(CDragSourceContextPeer.java:84)
at java.awt.dnd.DragSource.startDrag(DragSource.java:321)
at java.awt.dnd.DragSource.startDrag(DragSource.java:396)
at java.awt.dnd.DragGestureEvent.startDrag(DragGestureEvent.java:291)
at se.timeedit.window.dnd.DragAndDropTransferHandler.dragGestureRecognized(DragAndDropTransferHandler.java:220)
at java.awt.dnd.DragGestureRecognizer.fireDragGestureRecognized(DragGestureRecognizer.java:359)

Following is a quick output of the chain of components checked when the drag is started. What the sun.* code seems to be doing is loop upward through the parent chain, looking for non-lightweight components, then fetching its native peer, getting some kind of model from it then doing the above brutal cast which fails when the applet is inside the browser.

Lightweight: true class: class se.timeedit.calwindow.calendar.table.CalendarTableCanvas
Lightweight: true class: class se.timeedit.calwindow.calendar.table.CalendarTableView
sun.awt.NullComponentPeer@2faab9a1
Lightweight: true class: class se.timeedit.calwindow.calendar.CalendarView
sun.awt.NullComponentPeer@2faab9a1
Lightweight: true class: class se.timeedit.calwindow.CalendarMainPanel
sun.awt.NullComponentPeer@2faab9a1
Lightweight: true class: class javax.swing.JPanel
sun.awt.NullComponentPeer@2faab9a1
Lightweight: true class: class javax.swing.JLayeredPane
sun.awt.NullComponentPeer@2faab9a1
Lightweight: true class: class javax.swing.JRootPane
sun.awt.NullComponentPeer@2faab9a1
Lightweight: true class: class javax.swing.JInternalFrame
sun.awt.NullComponentPeer@2faab9a1
Lightweight: true class: class se.timeedit.main.TimeEditDesktopPane
sun.awt.NullComponentPeer@2faab9a1
Lightweight: false class: class se.timeedit.main.TimeEditApplet
sun.lwawt.LWPanelPeer@71811179
Lightweight: false class: class sun.plugin2.main.client.PluginEmbeddedFrame
sun.lwawt.LWWindowPeer@50a25926 [target is sun.plugin2.main.client.PluginEmbeddedFrame[frame0,178,119,1260x768,invalid,layout=java.awt.BorderLayout,title=,resizable,normal]]
Source: se.timeedit.window.dnd.DragAndDropGestureRecognizer@528af725
Drag source: java.awt.dnd.DragSource@249a9111
Default source: class java.awt.dnd.DragSource

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
darkcrawler
Offline
Joined: 2009-02-05
Points: 0

Hi there,

I tested the drag and drop in the application I'm validation - also a Swing application that runs as an applet inside a browser - and I got the same exception. I'm using JRE 1.7.0_08 and mac osx 10.7.4.

I struggled with this before and I could never make the drag and drop to work on mac osx. As a workaround - with java 6 - you could detach the frame out of the browser (on mac you can use cmd+shift for that) and once you do that, you could use the drag and drop without problems. So, the drag and drop did not work only when the applet runs inside the browser.

On Java 7 you get this exception when you try to use the drag and drop and the workaround we had in Java 6 is also not working, which fire and exception if you press cmd+shift. So basically, with Java 7 is even worse...

With this validation I'm doing I already report 2 bugs in Sun's BugParade. They were both accepted as bugs but with priorities changed to low and I think that one is pretty nasty (7196264) which only happens in Java 7.

bjoreman
Offline
Joined: 2009-02-15
Points: 0

Nice to at least finally find some more people who have not only encountered the very same bugs but also reported them. Now, if only it would be fixed or at least some workaround (horrific hack or not) could be found :-) …

bjoreman
Offline
Joined: 2009-02-15
Points: 0

For reference, I have now reported this as a bug too: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7197576

darkcrawler
Offline
Joined: 2009-02-05
Points: 0

Any news on this problem?

And what happens to the bug you reported? I cannot find it...

bjoreman
Offline
Joined: 2009-02-15
Points: 0

Sadly, no news.

And good question, I can't find it either …