I've got a JTree as a drop target. I can drag leaf elements around within the tree just fine, and the cursor changes as appropriate when it's over a legal vs. illegal drop location. I have another drag source which is a JList in the same layout. I can drag from there and successfully drop onto the JTree (the list is NOT a drop target, btw). However, the cursor never changes when the drag is from the JList, it always shows a no-drop icon. I can drop, and the elements are successfully copied, but the cursor never changes. What am I doing wrong here?
I also want to control the type of cursor shown based on the drag source. If the drag comes from the JList, it will only ever be a copy, never a move. Hence, I want to always show the copy cursor, regardless of what meta-keys the user may be using, attempting to change the type of drag and drop. The intra-JTree DnD, however, can be either a move or copy, as normal. Can I accomplish this at the Swing level, or do I have to resort to an AWT solution? Can the two live together?
Two wrongs don't make a right... but three lefts do.
Thanks! I discovered that limiting the source to just COPY will get you the COPY cursor, like you demonstrated. Somewhere along the line the cursor remaining no-drop even when over a valid drop zone, and even with a successful drop, went away.
I already have a working system with a somewhat complex transfer, in that objects coming from the JList are one type, while objects moving around in the JTree are another. When the transferable comes in from the JList, it gets converted to the appropriate type for insertion into the JTree. I do this with a custom DataFlavor and Transferable. The problem was just with the cursor not behaving correctly, which has since resolved.