Drag and Drop on a JPanel in JMEDesktop

Hi,



Trying to add drag'n'drop support to a JPanel I got the following:



java.lang.reflect.InvocationTargetException
        at java.awt.EventQueue.invokeAndWait(Unknown Source)
        at javax.swing.SwingUtilities.invokeAndWait(Unknown Source)
        at com.jmex.awt.swingui.JMEDesktop.onMove(JMEDesktop.java:446)
        at com.jmex.awt.swingui.JMEDesktop$XUpdateAction.performAction(JMEDesktop.java:1109)
        at com.jme.input.ActionTrigger.performAction(ActionTrigger.java:264)
        at com.jme.input.InputHandler.update(InputHandler.java:475)
        at com.jme.input.InputHandler.update(InputHandler.java:483)
        at de.worldofmystery.client.Client.update(Client.java:612)
        at com.jme.app.BaseGame.start(BaseGame.java:74)
        at de.worldofmystery.client.Client.main(Client.java:132)
Caused by: java.awt.dnd.InvalidDnDOperationException: Drag and drop in progress
        at sun.awt.dnd.SunDragSourceContextPeer.setDragDropInProgress(Unknown Source)
        at java.awt.dnd.DragSource.startDrag(Unknown Source)
        at java.awt.dnd.DragSource.startDrag(Unknown Source)
        at de.worldofmystery.client.gui.DesktopBag.dragGestureRecognized(DesktopBag.java:177)
        at java.awt.dnd.DragGestureRecognizer.fireDragGestureRecognized(Unknown Source)
        at sun.awt.windows.WMouseDragGestureRecognizer.mouseDragged(Unknown Source)
        at java.awt.Component.processMouseMotionEvent(Unknown Source)
        at javax.swing.JComponent.processMouseMotionEvent(Unknown Source)
        at java.awt.Component.processEvent(Unknown Source)
        at java.awt.Container.processEvent(Unknown Source)
        at java.awt.Component.dispatchEventImpl(Unknown Source)
        at java.awt.Container.dispatchEventImpl(Unknown Source)
        at java.awt.Component.dispatchEvent(Unknown Source)
        at com.jmex.awt.swingui.JMEDesktop.dispatchEvent(JMEDesktop.java:617)
        at com.jmex.awt.swingui.JMEDesktop.sendAWTMouseEvent(JMEDesktop.java:796)
        at com.jmex.awt.swingui.JMEDesktop.access$1000(JMEDesktop.java:101)
        at com.jmex.awt.swingui.JMEDesktop$8.run(JMEDesktop.java:448)
        at java.awt.event.InvocationEvent.dispatch(Unknown Source)
        at java.awt.EventQueue.dispatchEvent(Unknown Source)
        at java.awt.EventDispatchThread.pumpOneEventForHierarchy(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)



Is there a chance to get this working? Maybe I did something wrong?

Looks like normal Swing behaviour to me. Have you tested your code in a plain JFrame first?

Is this a jME question?  :wink:

Yes, it works in plain swing in a JDesktopPane but not in JmeDesktop so I think this is a jme question.

The only thing I wanted to know if drag and drop is supposed to work on a JmeDesktop.

It looks like I was not specific enough …



Here is a simple example for a drag and drop enabled JInternalFrame with a Swing test applet and a patch to TestJmeDesktop. Running that you can see that the same JInternalFrame with DnD works in Swing but not in JmeDesktop.



JInternalFrame with very simple drag and drop actions and the implementation  for dragging text:

http://www.world-of-mystery.de/download/DndPanel.java

http://www.world-of-mystery.de/download/TransferableText.java



Swing applet to test the above JInternalFrame:

http://www.world-of-mystery.de/download/TestSwingDesktop.java



Patch to add it to TestJmeDesktop:

http://www.world-of-mystery.de/download/desktop-test.diff

Hmm, ok, no idea then :expressionless: - I havn't used dnd in swing a lot… seems you have to figure out what the difference is and why swing believes dnd is already in progress…

I found out a bit more:

The stack trace I posted only occurs when I retry to drag. The problem seems to be that there is never a drop event on JmeDesktop. Swing is right in telling me there is already a drag active. I think it has something to do with the AWT events handling in JmeDesktop. The DragGestureRecognizer works and I can start the drag but it will never end - neither cancelled nor with a drop action.



That's what I need drag and drop for: http://www.world-of-mystery.de/download/screen00032.png

If you can find out what events are actually missing for swing to recognize the end of the drag, I can surely add them to JMEDesktop as well…



Nice app btw :slight_smile:

According to an AWTEventListener log I have two problems:

  • In the WoM client I got the drag exception, i.e. the DragGestureEvent was called.
  • In the TestJMEDesktop the gesture is not recognized at all.



    This is from TestSwingDesktop where drag and drop works:


java.awt.event.MouseEvent[MOUSE_PRESSED,(99,49),button=1,modifiers=Button1,extModifiers=Button1,clickCount=1] on DndPanel1
java.awt.event.MouseEvent[MOUSE_DRAGGED,(99,50),button=0,modifiers=Button1,extModifiers=Button1,clickCount=0] on DndPanel1
java.awt.event.MouseEvent[MOUSE_DRAGGED,(100,52),button=0,modifiers=Button1,extModifiers=Button1,clickCount=0] on DndPanel1
java.awt.event.MouseEvent[MOUSE_DRAGGED,(104,58),button=0,modifiers=Button1,extModifiers=Button1,clickCount=0] on DndPanel1
===DRAG===
java.awt.event.ComponentEvent[COMPONENT_MOVED (0,0 800x600)] on frame0
java.awt.event.HierarchyEvent[ANCESTOR_MOVED (javax.swing.JFrame[frame0,0,0,800x600,invalid,layout=java.awt.BorderLayout,title=TestSwingDesktop,resizable,normal,defaultCl
java.awt.event.HierarchyEvent[ANCESTOR_MOVED (javax.swing.JFrame[frame0,0,0,800x600,invalid,layout=java.awt.BorderLayout,title=TestSwingDesktop,resizable,normal,defaultCl
java.awt.event.HierarchyEvent[ANCESTOR_MOVED (javax.swing.JFrame[frame0,0,0,800x600,invalid,layout=java.awt.BorderLayout,title=TestSwingDesktop,resizable,normal,defaultCl
java.awt.event.HierarchyEvent[ANCESTOR_MOVED (javax.swing.JFrame[frame0,0,0,800x600,invalid,layout=java.awt.BorderLayout,title=TestSwingDesktop,resizable,normal,defaultCl
java.awt.event.HierarchyEvent[ANCESTOR_MOVED (javax.swing.JFrame[frame0,0,0,800x600,invalid,layout=java.awt.BorderLayout,title=TestSwingDesktop,resizable,normal,defaultCl
java.awt.event.HierarchyEvent[ANCESTOR_MOVED (javax.swing.JFrame[frame0,0,0,800x600,invalid,layout=java.awt.BorderLayout,title=TestSwingDesktop,resizable,normal,defaultCl
java.awt.event.HierarchyEvent[ANCESTOR_MOVED (javax.swing.JFrame[frame0,0,0,800x600,invalid,layout=java.awt.BorderLayout,title=TestSwingDesktop,resizable,normal,defaultCl
java.awt.event.HierarchyEvent[ANCESTOR_MOVED (javax.swing.JFrame[frame0,0,0,800x600,invalid,layout=java.awt.BorderLayout,title=TestSwingDesktop,resizable,normal,defaultCl
java.awt.event.HierarchyEvent[ANCESTOR_MOVED (javax.swing.JFrame[frame0,0,0,800x600,invalid,layout=java.awt.BorderLayout,title=TestSwingDesktop,resizable,normal,defaultCl
java.awt.event.HierarchyEvent[ANCESTOR_MOVED (javax.swing.JFrame[frame0,0,0,800x600,invalid,layout=java.awt.BorderLayout,title=TestSwingDesktop,resizable,normal,defaultCl
java.awt.event.HierarchyEvent[ANCESTOR_MOVED (javax.swing.JFrame[frame0,0,0,800x600,invalid,layout=java.awt.BorderLayout,title=TestSwingDesktop,resizable,normal,defaultCl
java.awt.event.HierarchyEvent[ANCESTOR_MOVED (javax.swing.JFrame[frame0,0,0,800x600,invalid,layout=java.awt.BorderLayout,title=TestSwingDesktop,resizable,normal,defaultCl
java.awt.event.HierarchyEvent[ANCESTOR_MOVED (javax.swing.JFrame[frame0,0,0,800x600,invalid,layout=java.awt.BorderLayout,title=TestSwingDesktop,resizable,normal,defaultCl
java.awt.event.HierarchyEvent[ANCESTOR_MOVED (javax.swing.JFrame[frame0,0,0,800x600,invalid,layout=java.awt.BorderLayout,title=TestSwingDesktop,resizable,normal,defaultCl
java.awt.event.HierarchyEvent[ANCESTOR_MOVED (javax.swing.JFrame[frame0,0,0,800x600,invalid,layout=java.awt.BorderLayout,title=TestSwingDesktop,resizable,normal,defaultCl
java.awt.event.HierarchyEvent[ANCESTOR_MOVED (javax.swing.JFrame[frame0,0,0,800x600,invalid,layout=java.awt.BorderLayout,title=TestSwingDesktop,resizable,normal,defaultCl
java.awt.event.HierarchyEvent[ANCESTOR_MOVED (javax.swing.JFrame[frame0,0,0,800x600,invalid,layout=java.awt.BorderLayout,title=TestSwingDesktop,resizable,normal,defaultCl
java.awt.event.HierarchyEvent[ANCESTOR_MOVED (javax.swing.JFrame[frame0,0,0,800x600,invalid,layout=java.awt.BorderLayout,title=TestSwingDesktop,resizable,normal,defaultCl
java.awt.event.HierarchyEvent[ANCESTOR_MOVED (javax.swing.JFrame[frame0,0,0,800x600,invalid,layout=java.awt.BorderLayout,title=TestSwingDesktop,resizable,normal,defaultCl
java.awt.event.HierarchyEvent[ANCESTOR_MOVED (javax.swing.JFrame[frame0,0,0,800x600,invalid,layout=java.awt.BorderLayout,title=TestSwingDesktop,resizable,normal,defaultCl
java.awt.event.HierarchyEvent[ANCESTOR_MOVED (javax.swing.JFrame[frame0,0,0,800x600,invalid,layout=java.awt.BorderLayout,title=TestSwingDesktop,resizable,normal,defaultCl
java.awt.event.HierarchyEvent[ANCESTOR_MOVED (javax.swing.JFrame[frame0,0,0,800x600,invalid,layout=java.awt.BorderLayout,title=TestSwingDesktop,resizable,normal,defaultCl
java.awt.event.HierarchyEvent[ANCESTOR_MOVED (javax.swing.JFrame[frame0,0,0,800x600,invalid,layout=java.awt.BorderLayout,title=TestSwingDesktop,resizable,normal,defaultCl
java.awt.event.HierarchyEvent[ANCESTOR_MOVED (javax.swing.JFrame[frame0,0,0,800x600,invalid,layout=java.awt.BorderLayout,title=TestSwingDesktop,resizable,normal,defaultCl
java.awt.event.HierarchyEvent[ANCESTOR_MOVED (javax.swing.JFrame[frame0,0,0,800x600,invalid,layout=java.awt.BorderLayout,title=TestSwingDesktop,resizable,normal,defaultCl
java.awt.event.HierarchyEvent[ANCESTOR_MOVED (javax.swing.JFrame[frame0,0,0,800x600,invalid,layout=java.awt.BorderLayout,title=TestSwingDesktop,resizable,normal,defaultCl
java.awt.event.HierarchyEvent[ANCESTOR_MOVED (javax.swing.JFrame[frame0,0,0,800x600,invalid,layout=java.awt.BorderLayout,title=TestSwingDesktop,resizable,normal,defaultCl
java.awt.event.HierarchyEvent[ANCESTOR_MOVED (javax.swing.JFrame[frame0,0,0,800x600,invalid,layout=java.awt.BorderLayout,title=TestSwingDesktop,resizable,normal,defaultCl
java.awt.event.HierarchyEvent[ANCESTOR_MOVED (javax.swing.JFrame[frame0,0,0,800x600,invalid,layout=java.awt.BorderLayout,title=TestSwingDesktop,resizable,normal,defaultCl
java.awt.event.HierarchyEvent[ANCESTOR_MOVED (javax.swing.JFrame[frame0,0,0,800x600,invalid,layout=java.awt.BorderLayout,title=TestSwingDesktop,resizable,normal,defaultCl
===DROP===
java.awt.event.MouseEvent[MOUSE_EXITED,(214,176),button=0,clickCount=0] on DndPanel1
java.awt.event.MouseEvent[MOUSE_ENTERED,(99,29),button=0,clickCount=0] on null.glassPane
java.awt.event.MouseEvent[MOUSE_ENTERED,(104,56),button=0,clickCount=0] on DndPanel2



This is a log from TestJMEDesktop. The PRESSED and DRAGGED events are on JLabel, not on the panel as above and that's why I miss the DragGestureEvent.


java.awt.event.MouseEvent[MOUSE_PRESSED,(38,34),button=0,modifiers=Button1,extModifiers=Button1,clickCount=0] on javax.swing.JLabel[,0,0,190x68,alignmentX=0.0,alignmentY=
java.awt.event.MouseEvent[MOUSE_DRAGGED,(39,34),button=0,modifiers=Button1,extModifiers=Button1,clickCount=0] on javax.swing.JLabel[,0,0,190x68,alignmentX=0.0,alignmentY=
java.awt.event.MouseEvent[MOUSE_DRAGGED,(39,37),button=0,modifiers=Button1,extModifiers=Button1,clickCount=0] on javax.swing.JLabel[,0,0,190x68,alignmentX=0.0,alignmentY=
java.awt.event.MouseEvent[MOUSE_DRAGGED,(40,37),button=0,modifiers=Button1,extModifiers=Button1,clickCount=0] on javax.swing.JLabel[,0,0,190x68,alignmentX=0.0,alignmentY=
java.awt.event.MouseEvent[MOUSE_DRAGGED,(40,39),button=0,modifiers=Button1,extModifiers=Button1,clickCount=0] on javax.swing.JLabel[,0,0,190x68,alignmentX=0.0,alignmentY=
java.awt.event.MouseEvent[MOUSE_DRAGGED,(41,39),button=0,modifiers=Button1,extModifiers=Button1,clickCount=0] on javax.swing.JLabel[,0,0,190x68,alignmentX=0.0,alignmentY=
java.awt.event.MouseEvent[MOUSE_DRAGGED,(41,41),button=0,modifiers=Button1,extModifiers=Button1,clickCount=0] on javax.swing.JLabel[,0,0,190x68,alignmentX=0.0,alignmentY=
java.awt.event.MouseEvent[MOUSE_DRAGGED,(41,42),button=0,modifiers=Button1,extModifiers=Button1,clickCount=0] on javax.swing.JLabel[,0,0,190x68,alignmentX=0.0,alignmentY=
java.awt.event.MouseEvent[MOUSE_DRAGGED,(45,42),button=0,modifiers=Button1,extModifiers=Button1,clickCount=0] on javax.swing.JLabel[,0,0,190x68,alignmentX=0.0,alignmentY=
...
java.awt.event.MouseEvent[MOUSE_DRAGGED,(76,132),button=0,modifiers=Button1,extModifiers=Button1,clickCount=0] on javax.swing.JLabel[,0,0,190x68,alignmentX=0.0,alignmentY
java.awt.event.MouseEvent[MOUSE_RELEASED,(76,132),button=0,modifiers=Button1,extModifiers=Button1,clickCount=0] on javax.swing.JLabel[,0,0,190x68,alignmentX=0.0,alignment
java.awt.event.MouseEvent[MOUSE_MOVED,(76,21),button=0,clickCount=0] on null.glassPane


So what should actually be changed? Do you know for which conditions the target is different? Or which events actually would have to be generated by JMEDesktop to make things work?

I'd love to tell you what exactly the problem is - only problem is, I don't know.



What I could see in the debug output of the AWTListener is that the MOUSE_DRAGGED is sent to the JLabel instead of the parent DndPanel1 which is a JInternalFrame. The JLabel uses all the space in the JInternalFrame and to be honest I don't know how the events should be distributed in such a case. Magically it works as expected in plain swing.


I tried again in WoM client and the events MOUSE_PRESSED, MOUSE_CLICKED and MOUSE_DRAGGED are dispatched to the DesktopBag as they should. It looks a bit random to me as in the test I always had the events on the wrong target.

Nevertheless the drop is never called.

Has anybody enough knowledge of the AWT events to fix the drag and drop problem?

Whatever you use, the problem will always be there :slight_smile: even with web start you are bound to the jvm …

I just tried to keep the loader as generic as possible for my purposes and upto now it works.

Galun said:

I tried again in WoM client and the events MOUSE_PRESSED, MOUSE_CLICKED and MOUSE_DRAGGED are dispatched to the DesktopBag as they should. It looks a bit random to me as in the test I always had the events on the wrong target.
Nevertheless the drop is never called.
Has anybody enough knowledge of the AWT events to fix the drag and drop problem?

The next thing on my todo list after implementing an "autoupdateservice" for our game.
Give me one more wekk and we might have a look together at it.

That sounds promising :slight_smile:



If you are interested in auto-update: I had the same problem and solved it with two calls to java. The first one takes care about new files to download and the second is the actual client. The part that loads all needed files uses a gzip socket to compress the files on the fly.

See the directories fileserver and loader on http://cvs.world-of-mystery.de/cgi-bin/cvsweb.cgi/wom/src/de/worldofmystery/

offtopic i know, but have you guys looked at install4j or any of the others installers that promise auto update. The issue is - what if you have to update the updater

Back to the topic: I enabled all types in the AWT listener and build another test program (a Swing Applet that uses the very same DesktopBag which is a drag and drop source and target).



The trace of the Swing applet shows :


FEIN: AWT:java.awt.event.MouseEvent[MOUSE_DRAGGED,(40,21),button=0,modifiers=Button1,extModifiers=Button1,clickCount=0] on de.worldofmystery.client.gui.DesktopBag[,0,0,19
0x168,layout=java.awt.FlowLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize=java.awt.Dimension[width=64,height=64]]
01.04.2006 01:39:52 de.worldofmystery.client.gui.TestDesktop$1 eventDispatched
FEIN: AWT:java.awt.event.MouseEvent[MOUSE_DRAGGED,(41,21),button=0,modifiers=Button1,extModifiers=Button1,clickCount=0] on de.worldofmystery.client.gui.DesktopBag[,0,0,19
0x168,layout=java.awt.FlowLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize=java.awt.Dimension[width=64,height=64]]
01.04.2006 01:39:52 de.worldofmystery.client.gui.TestDesktop$1 eventDispatched
FEIN: AWT:java.awt.event.MouseEvent[MOUSE_DRAGGED,(42,22),button=0,modifiers=Button1,extModifiers=Button1,clickCount=0] on de.worldofmystery.client.gui.DesktopBag[,0,0,19
0x168,layout=java.awt.FlowLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize=java.awt.Dimension[width=64,height=64]]
01.04.2006 01:39:52 de.worldofmystery.client.gui.DesktopBag dragGestureRecognized
FEIN: java.awt.dnd.DragGestureEvent[source=sun.awt.X11.XMouseDragGestureRecognizer@bf2d5e]
01.04.2006 01:39:52 de.worldofmystery.client.gui.DesktopBag dragGestureRecognized
FEIN: hotspot=java.awt.Point[x=32,y=32]
01.04.2006 01:39:52 de.worldofmystery.client.gui.TestDesktop$1 eventDispatched
FEIN: AWT:java.awt.event.ComponentEvent[COMPONENT_MOVED (0,0 808x676)] on frame0
01.04.2006 01:39:52 de.worldofmystery.client.gui.TestDesktop$1 eventDispatched
FEIN: AWT:java.awt.event.HierarchyEvent[ANCESTOR_MOVED (sun.applet.AppletViewer[frame0,0,0,808x676,invalid,layout=java.awt.BorderLayout,title=Applet-Ansicht: de.worldofmy
stery.client.gui.TestDesktop.class,resizable,normal],null)] on null.glassPane
01.04.2006 01:39:52 de.worldofmystery.client.gui.TestDesktop$1 eventDispatched



and in JMEDesktop it is:


FEIN: AWT:java.awt.event.MouseEvent[MOUSE_DRAGGED,(85,102),button=0,modifiers=Button1,extModifiers=Button1,clickCount=0] on de.worldofmystery.client.gui.DesktopBag[,0,0,3
00x200,layout=java.awt.FlowLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize=java.awt.Dimension[width=300,height=200]]
01.04.2006 01:43:43 de.worldofmystery.client.WomDesktop$1 eventDispatched
FEIN: AWT:java.awt.event.MouseEvent[MOUSE_DRAGGED,(85,100),button=0,modifiers=Button1,extModifiers=Button1,clickCount=0] on de.worldofmystery.client.gui.DesktopBag[,0,0,3
00x200,layout=java.awt.FlowLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize=java.awt.Dimension[width=300,height=200]]
01.04.2006 01:43:43 de.worldofmystery.client.WomDesktop$1 eventDispatched
FEIN: AWT:java.awt.event.MouseEvent[MOUSE_DRAGGED,(81,100),button=0,modifiers=Button1,extModifiers=Button1,clickCount=0] on de.worldofmystery.client.gui.DesktopBag[,0,0,3
00x200,layout=java.awt.FlowLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize=java.awt.Dimension[width=300,height=200]]
01.04.2006 01:43:43 de.worldofmystery.client.gui.DesktopBag dragGestureRecognized
FEIN: java.awt.dnd.DragGestureEvent[source=sun.awt.X11.XMouseDragGestureRecognizer@8f3d27]
01.04.2006 01:43:43 de.worldofmystery.client.gui.DesktopBag dragGestureRecognized
FEIN: hotspot=java.awt.Point[x=32,y=32]
01.04.2006 01:43:43 de.worldofmystery.client.WomDesktop$1 eventDispatched
FEIN: AWT:java.awt.event.MouseEvent[MOUSE_DRAGGED,(81,98),button=0,modifiers=Button1,extModifiers=Button1,clickCount=0] on de.worldofmystery.client.gui.DesktopBag[,0,0,30
0x200,layout=java.awt.FlowLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize=java.awt.Dimension[width=300,height=200]]
01.04.2006 01:43:43 de.worldofmystery.client.WomDesktop$1 eventDispatched
FEIN: AWT:java.awt.event.MouseEvent[MOUSE_DRAGGED,(81,97),button=0,modifiers=Button1,extModifiers=Button1,clickCount=0] on de.worldofmystery.client.gui.DesktopBag[,0,0,30
0x200,layout=java.awt.FlowLayout,alignmentX=0.0,alignmentY=0.0,border=,flags=9,maximumSize=,minimumSize=,preferredSize=java.awt.Dimension[width=300,height=200]]
01.04.2006 01:43:43 de.worldofmystery.client.WomDesktop$1 eventDispatched



i.e. in JMEDesktop there are still MOUSE_DRAGGED events where there should be COMPONENT_MOVED and ANCESTOR_MOVED events.

BTW: In JMEDesktop the MOUSE_DRAGGED has a clickCount>0 which does not happen in pure Swing. First I thought this might be the problem, but obviously it's not. The following patch makes the MOUSE_DRAGGED events look the same as in pure Swing:


Index: src/com/jmex/awt/swingui/JMEDesktop.java
===================================================================
RCS file: /cvs/jme/src/com/jmex/awt/swingui/JMEDesktop.java,v
retrieving revision 1.34
diff -u -r1.34 JMEDesktop.java
--- src/com/jmex/awt/swingui/JMEDesktop.java

good you are advancing here - I won't have the time to debug it myself (and don't know from the top of my head what could be wrong)

The main question for me is: Is JMEDesktop responsible to create and send these events or should it dispatch the mouse events to something that handles drag and drop? I found something named SunDragSourceContextPeer which seems to come into the play when a drag is active. On the other hand the dispatchEvent() functions look like they should take care about the dispatching to the right target.



I think with some effort we could create the appropriate events in JMEDesktop but somehow I have the feeling this would be a hack and not the right way to do that.



As we can see in the debug output of the swing applet the MOUSE_DRAGGED events are no longer there when the drag has been started and they are replaced by "higher level" events like the COMPONENT_MOVED and they seem to come from a parent, not the drag source. In the case of JMEDesktop would that be the instance responsible for that? In the swing applet the frame0 mentioned in the events seems to be the parent of the JDesktopPane. As far as I understood JMEDesktop does not have a parent? Would it need one or does that mean it should do what the frame0 does for the applet?


Well, it would definately be better if swing would create the drag events from the mouse events somehow. But possibly this won't work. In the worst case JMEDesktop would have to generate them. Try to find out why and how swing normally generates those events and if possible find out how to make it create them while JMEDesktop is used.



Btw - this seems to get quite complicated - what about using mouse dragged events in your app and fake the component dragging instead? (simply move your components yourself)