Is it possible to DnD from JDialog to JFrame?

Hello!Is it possible to perform drag and drop from JDialog to JFrame?If yes, what is the oldest JDK that supports it?It would be great if you post any helpful code chunk :)Thanks in advance!
[225 byte] By [Andriy_Tsykholyasa] at [2007-10-3 8:50:18]
# 1
[url http://java.sun.com/docs/books/tutorial/uiswing/misc/dnd.html]How to Use Drag and Drop[/url].Open up two versions of the same application and try dragging between the two of them.
camickra at 2007-7-15 3:59:42 > top of Java-index,Desktop,Core GUI APIs...
# 2
> Is it possible to perform drag and drop from JDialog> to JFrame?I've missed one important detail: JDialog mentioned above is modal...There is no problem with DnD if dialog is non-modal.
Andriy_Tsykholyasa at 2007-7-15 3:59:42 > top of Java-index,Desktop,Core GUI APIs...
# 3

> [url

> http://java.sun.com/docs/books/tutorial/uiswing/misc/d

> nd.html]How to Use Drag and Drop[/url].

Thanks for this link. In fact I've read it before posting my question here. Unfortunately there is no mentioning about dialogs :(

And [url http://java.sun.com/docs/books/tutorial/uiswing/components/dialog.html]How to Make Dialogs[/url] is not helpful for this issue also.

> Open up two versions of the same application and try

> dragging between the two of them.

I understand this. Also possible solution is to replace JDialog with another JFrame. Then there will be DnD from one JFrame to another JFrame. The problem is that DnD source is JDialog, modal one... :(

Andriy_Tsykholyasa at 2007-7-15 3:59:42 > top of Java-index,Desktop,Core GUI APIs...
# 4
The only solution I've found is:1) switch dialog to non-modal state (this requires hide and show operatons),2) perform DnD, 3) switch dialog to modal state again (hide and show is needed again).But this is bad solution...
Andriy_Tsykholyasa at 2007-7-15 3:59:42 > top of Java-index,Desktop,Core GUI APIs...
# 5

I've not tried this - it seems an odd requirement, and to be honest I'd need convincing that there exists a scenario where it's appropriate to have modality and the ability to drag between frames, I'd instictively think they'd be mutually exclusive - but, pondering a workaorund, you could try something along the lines of the following.

You could try coding a 'fake' DnD implementation, ie handle the mouse events and change the cursor manually. When you get a release event after a drag, you determine the location of that event on the screen (ie add together MouseEvent.getPoint() and Component.getLocationOnScreen()). From that you should be able to access the component in the target frame (using Component.getComponentAt() - a Window is a Component of course).

I dunno - maybe that wouldn't work, I'd need to play around with it. But I reckon it's doable. Just a thought.

itchyscratchya at 2007-7-15 3:59:42 > top of Java-index,Desktop,Core GUI APIs...
# 6
Thanks for help.But the problem is that no drag event is recieved by drop target (no window can recieve such events when modal dialog is showing).Anyway, I used non-modal dialog and it works acceptable.
Andriy_Tsykholyasa at 2007-7-15 3:59:43 > top of Java-index,Desktop,Core GUI APIs...