DefaultMutableTreeNode target, DefaultMutableTreeNode before) { DataFlavor[] flavors = t.getTransferDataFlavors(); int action = isDroppable(flavors, target); if (action != DnDConstants.ACTION_NONE) { try { Object userData = t.getTransferData(flavors[0]); DefaultMutableTreeNode node = new DefaultMutableTreeNode(userData, userData instanceof String); int ix = target.getChildCount(); if (before != null) { ix = model.getIndexOfChild(target, before); } if(log.isDebugEnabled()) { log.debug("Insert into " + target + " at " + ix + " before " + before); } model.insertNodeInto(node, target, ix); selectNode(node); return action; } catch (Exception e) { if(log.isErrorEnabled()) { log.error("Caught an exception", e); } } }
DefaultMutableTreeNode target, DefaultMutableTreeNode before) { DataFlavor[] flavors = t.getTransferDataFlavors(); int action = isDroppable(flavors, target); if (action == DnDConstants.ACTION_NONE) return action; Object data = null; try { data = t.getTransferData(flavors[0]); } catch (Exception e) { if(log.isErrorEnabled()) { log.error("Exception adding dropped element:", e);
    public int addElement(Transferable t,                          DefaultMutableTreeNode target,                          DefaultMutableTreeNode before) {        DataFlavor[] flavors = t.getTransferDataFlavors();        int action = isDroppable(flavors, target);        if (action != DnDConstants.ACTION_NONE) {            try {                Object userData = t.getTransferData(flavors[0]);                DefaultMutableTreeNode node =                    new DefaultMutableTreeNode(userData, userData instanceof String);                int ix = target.getChildCount();                if (before != null) {                    ix = model.getIndexOfChild(target, before);                }                if(log.isDebugEnabled()) {                  log.debug("Insert into " + target + " at " + ix + " before " + before);                }                model.insertNodeInto(node, target, ix);                selectNode(node);                return action;  // Always MOVE            } catch (Exception e) {              if(log.isErrorEnabled()) {                log.error("Caught an exception", e);              }            }        }        return DnDConstants.ACTION_NONE;    }