JTree.DropLocation loc = (JTree.DropLocation) support.getDropLocation();
Object parent = loc.getPath().getLastPathComponent();
int index = loc.getChildIndex();
if(index==-1) { // We're dropping "ON" something
if(parent instanceof Frame) {
Frame frame = (Frame) parent;
index = frame.getParent().getFrameIndex(frame)+1;
parent = frame.getParent();
} else if(parent instanceof Animation) {
index = ((Animation) parent).getFrameCount();
}
}
if(parent instanceof Animation) {
try {
Frame[] frames = (Frame[]) support.getTransferable().getTransferData(FrameFlavor);
if(support.getDropAction() == COPY)
for(Frame frame:frames) ((Animation) parent).addFrame(frame.clone(),index++);
else if (support.getDropAction() == MOVE) {
index--;
for(Frame frame:frames) index = frame.move(parent,index);
}
return true;
} catch (Exception e) {
e.printStackTrace();
return false;