Win a copy of Practical SVG this week in the HTML/CSS/JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Drag and Drop between JFrames freezes

 
Steffen Foldager
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys
I'm trying to do a Drag and Drop between two JFrames, but my application freezes totally when I drag from one JFrame to another.
The DnD source is a JFrame with a JTable that implements DragGestureListener. The target is a JFrame with a JTable that implements DropTargetListener and DragGestureListener. I just want a very simple DnD without DataFlavors and Transferables, in other words I am happy if I get the selected line numbers from the source table. I have succeeded in doing this with two JTables within the same JFrame. But now I have two JFrames and the freeze occurs.
It occurs the second I drag the selected lines over the source JFrame (not the actual JTable). The application then takes 100% CPU time and can only be killed via Windows Task Manager (W2000). On XP Pro, the application can't be killed at all!!! No Exceptions are thrown.
Has anyone come across this scenario before and could give me a hint of direction?
Regards and thanks,
Steffen
 
Steffen Foldager
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I managed to isolate the Thread that used 100% CPU and here is the call stack. It doesn't make much sense to me, I'm afraid..
Thread [AWT-Windows] (Suspended)
sun.awt.windows.WToolkitThreadBlockedHandler.startSecondaryEventLoop() line: not available [native method]
sun.awt.windows.WToolkitThreadBlockedHandler.enter() line: 296
sun.awt.windows.WDropTargetContextPeer(sun.awt.dnd.SunDropTargetContextPeer).handleEnterMessage(java.awt.Component, int, int, int, int, long[], long) line: 281
sun.awt.windows.WToolkit.eventLoop() line: not available [native method]
sun.awt.windows.WToolkit.run() line: 240
java.lang.Thread.run() line: 536
 
Steffen Foldager
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
HURRRAAH!
This one took me quite a while, so I thought I might share my joy with the rest of you:
The reason for the freeze was that I was dragging from a JDialog that was modal to the JFrame I was dropping to.
So remember this: Dragging from JDialogs into modal parent frames is BAD!!! (At least in Java 1.4)
Steffen
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!