Bonjour,

J'ai déjà un événement MouseListener sur mon JTree (menu contextuel) et je désire ajouter du drag & drop. Je suis les recommandations du tutorial en appelant

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
jTree.setDragEnabled(true);
jTree.setTransferHandler(new TreePathTransferHandler(jTreeCibles, DnDConstants.ACTION_COPY_OR_MOVE));
Toutefois, comme j'ai déjà un MouseListener attaché à cet arbre, le transferHandler ne reçois pas l'événement de la souris pour le DragGestureEvent. Toutefois, si je commente ou j'enlève le MouseListener existant (pour le menu contextuel), le DnD fonctionne normalement.

Quelqu'un a-t-il une idée pourquoi l'événement ne se rend pas au DragGestureListener quand on a déjà un MouseListener?


Quand ça marche, voici la pile des appels (call stack) :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
TreePathTransferHandler.createTransferable(JComponent) line: 71
TransferHandler$DragHandler.dragGestureRecognized(DragGestureEvent) line: not available
TransferHandler$SwingDragGestureRecognizer(DragGestureRecognizer).fireDragGestureRecognized(int, Point) line: not available
TransferHandler$SwingDragGestureRecognizer.gestured(JComponent, MouseEvent, int, int) line: not available
TreePathTransferHandler(TransferHandler).exportAsDrag(JComponent, InputEvent, int) line: not available
TreePathTransferHandler.exportAsDrag(JComponent, InputEvent, int) line: 86
BasicTreeUI$TreeDragGestureRecognizer(BasicDragGestureRecognizer).mouseDragged(MouseEvent) line: not available
AWTEventMulticaster.mouseDragged(MouseEvent) line: not available
JTree(Component).processMouseMotionEvent(MouseEvent) line: not available
JTree(JComponent).processMouseMotionEvent(MouseEvent) line: not available
JTree(Component).processEvent(AWTEvent) line: not available
JTree(Container).processEvent(AWTEvent) line: not available
JTree(Component).dispatchEventImpl(AWTEvent) line: not available
JTree(Container).dispatchEventImpl(AWTEvent) line: not available
JTree(Component).dispatchEvent(AWTEvent) line: not available
LightweightDispatcher.retargetMouseEvent(Component, int, MouseEvent) line: not available
LightweightDispatcher.processMouseEvent(MouseEvent) line: not available
LightweightDispatcher.dispatchEvent(AWTEvent) line: not available
CiblesMenusFrame(Container).dispatchEventImpl(AWTEvent) line: not available
CiblesMenusFrame(Window).dispatchEventImpl(AWTEvent) line: not available
CiblesMenusFrame(Component).dispatchEvent(AWTEvent) line: not available
EventQueue.dispatchEvent(AWTEvent) line: not available
EventDispatchThread.pumpOneEventForHierarchy(int, Component) line: not available
EventDispatchThread.pumpEventsForHierarchy(int, Conditional, Component) line: not available
EventDispatchThread.pumpEvents(int, Conditional) line: not available
EventDispatchThread.pumpEvents(Conditional) line: not available
EventDispatchThread.run() line: not available