/** {@inheritDoc} */ public void dragEnter(DropTargetDragEvent evt) { target = (JComponent) evt.getDropTargetContext().getComponent(); TransferHandler th = target.getTransferHandler(); canImport = th.canImport(target, evt.getCurrentDataFlavors()); if (canImport) { saveComponentState(target); lastPosition = evt.getLocation(); } }
// ====================================================== // ====================================================== private void treeMousePressed(java.awt.event.MouseEvent evt) { int mask = evt.getModifiers(); if ((mask & MouseEvent.BUTTON1_MASK) != 0) { TreePath selectedPath = getPathForLocation(evt.getX(), evt.getY()); if (selectedPath == null) return; DefaultMutableTreeNode node = (DefaultMutableTreeNode) selectedPath.getPathComponent(selectedPath.getPathCount() - 1); Object o = node.getUserObject(); if (o instanceof String) { TransferHandler transfer = this.getTransferHandler(); transfer.exportAsDrag(this, evt, TransferHandler.COPY); dragged_node = node; parent.setCursor(renderer.getNodeCursor(node)); } } }
@Override public void exportToClipboard(JComponent comp, Clipboard clip, int action) { super.exportToClipboard(comp, clip, action); }