Friday, 15 February 2013

java - DragSource - InvalidDnDOperationException on starting DragAction -



java - DragSource - InvalidDnDOperationException on starting DragAction -

my application contains few jpanels sould moved dnd. have implemented listeners , handlers, seems right. when dragging 1 panel mouse draggesturelistener recognizes , wants start new dragaction:

@override public void draggesturerecognized(draggestureevent dge) { // when drag begins, need grab reference // parent container can homecoming if drop // rejected container parent = getpanel().getparent(); setparent(parent); // remove panel parent. if don't this, // can cause serialization issues. on come // allowing drop target remove component, that's // argument day parent.remove(getpanel()); // update display parent.invalidate(); parent.repaint(); // create our transferable wrapper tickettransferable transferable = new tickettransferable(getpanel()); // start "drag" process... dge.startdrag(null, transferable); }

but next exception occurs:

exception in thread "awt-eventqueue-0" java.awt.dnd.invaliddndoperationexception: cannot find top-level drag source component @ sun.awt.x11.xdragsourcecontextpeer.startdrag(xdragsourcecontextpeer.java:126) @ sun.awt.dnd.sundragsourcecontextpeer.startdrag(sundragsourcecontextpeer.java:134)

i checked xdragsourcecontextpeer , found out component triggers dragaction (in case jpanel move itself) must of type "window" start drag properly. point jpanel isnt window , mentioned exception thrown back.

what doing wrong?

p.s.: "moveable" panels in different cells of jtable.

java swing drag-and-drop

No comments:

Post a Comment