if (target != null) {   if (target.getAllowsChildren()) { DataFlavor[] possibleFlavors = event.getCurrentDataFlavors(); if (isDroppable(possibleFlavors, target) == DnDConstants.ACTION_NONE) { after = target; target = (DefaultMutableTreeNode)after.getParent(); }
DataFlavor[] possibleFlavors = event.getCurrentDataFlavors(); Transferable transferable = event.getTransferable(); while (target != null) { if (isAllowed(possibleFlavors, target)) { action = addElement(transferable, target, after); break;
  public void drop(DropTargetDropEvent event) {    int action = DnDConstants.ACTION_NONE;    DefaultMutableTreeNode target = getDropTarget(event.getLocation());    DefaultMutableTreeNode after = null;//      // if the target does not allow children, then drop on its parent//      if (target != null && !target.getAllowsChildren()) {//        after = target;//        target = (DefaultMutableTreeNode) after.getParent();//      }//      if (target != null) {//        Transferable transferable = event.getTransferable();//        action = addElement(transferable, target, after);//  //        System.out.println("Action " + action);//      }    if (target != null) {      // if the target allows children, but not of this type,       // then drop on the parent, after the original target      if (target.getAllowsChildren()) {        DataFlavor[] possibleFlavors = event.getCurrentDataFlavors();        if (isDroppable(possibleFlavors, target) == DnDConstants.ACTION_NONE) {          after = target;          target = (DefaultMutableTreeNode)after.getParent();        }      } else {        // the target does not allow children, so drop on its parent        // after the original target        after = target;        target = (DefaultMutableTreeNode) after.getParent();      }    }    if (target != null) {      Transferable transferable = event.getTransferable();      action = addElement(transferable, target, after);      //        System.out.println("Action " + action);    }    boolean success;    switch (action) {    case DnDConstants.ACTION_MOVE:    case DnDConstants.ACTION_COPY:      event.acceptDrop(action);      success = true;      break;    default:      event.rejectDrop();      success = false;      break;    }    event.getDropTargetContext().dropComplete(success);  }