aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Transfer drop to sub-component (need help with) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Transfer drop to sub-component (need help with)" Watch "Transfer drop to sub-component (need help with)" New topic
Author

Transfer drop to sub-component (need help with)

Diego Mendez Padilla
Greenhorn

Joined: Jun 19, 2010
Posts: 1
First of all, hello

My problem is this:

I've been messing with Swing and Drag and Drop functionalities for an application and learned a lot in a few weeks. I've managed to create color tiles that work with drag and drop; dragging the color from the color tile and dropping in another component that get's drawn with the chosen color. I wanted to display the components (lets call them drawings) in a list, and said list should support drag and drop. I've managed to drag the drawings from one list to another, and to add or remove more drawings with drag and drop.

But when I try to drag a color to a drawing inside a list, it doesn't work, the list is catching the drag instead of the drawing. Is there a way to transfer the drag to the drawing?

Note that some drawings use gradients, thus there is need to know where, in the drawing, the color was dropped. Also, the drag and drop of the drawings works just fine if they are outside the list.

I'm using a custom TransferHandler for the list (as well as a custom ListModel and a custom ListCellRenderer)
The color tiles and the drawings implement DragGestureListener, Transferable and DropTargetListener.
My code at this point involves a lot of classes so it is hard to show.

Thanks to everyone who take the time to read my problem, hope you can help me.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Transfer drop to sub-component (need help with)