• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Drag and drop on to an ImageView

 
Colin Smithworth
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I'm trying to enable being able to drag and drop files from the windows desktop to an ImageView inside my gui.

When I try this, I get a red circle with a line through showing by the file as I move it over the ImageView.

However...

If I press on the ImageView prior to dragging a file over it, then it works.


I'm not sure whats going on exactly, I'm essentially using this code for the drag over part:



So the "db has things!" line never shows when dragging over, unless I press on the ImageView first.

I'm not sure whats going on, any ideas please, thanks.
 
L Foster
Ranch Hand
Posts: 185
10
Android Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Colin.  Here is a simplistic explanation, which just _might_ be true. Could this be simply that you have caused your app to gain focus, prior to doing the mouseover?  Also, I think the "line-through" thing is just DnD's way of saying "this target is not accepting this type".  I hope that helps.
 
Colin Smithworth
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
L Foster wrote:Hi, Colin.  Here is a simplistic explanation, which just _might_ be true. Could this be simply that you have caused your app to gain focus, prior to doing the mouseover?  Also, I think the "line-through" thing is just DnD's way of saying "this target is not accepting this type".  I hope that helps.


Thanks for the reply...

Well the window with the ImageView is a second stage, if I move this window first by dragging it at the top, then when I drag and drop onto the ImageView, nothing happens.
I have to literally press somewhere on the window first, then I am allowed to drag and drop.

I would think the window being focused would be required for the drag and drop, I tried ImageView.requestFocus(), after it is created, but that doesn't make any difference.

Maybe it has something to do with the other stage, if I press on that, then the drag and drop also works on this stage.

Let me know if you have any thoughts, thanks.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic