public void drop(DropTargetDropEvent evt) {
    try {
      Transferable t = evt.getTransferable();

      if (t.isDataFlavorSupported(DataFlavor.stringFlavor)) {
        evt.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);

        String s = (String) t.getTransferData(DataFlavor.stringFlavor);
        evt.getDropTargetContext().dropComplete(true);
        process(s);
      } else {
        evt.rejectDrop();
      }
    } catch (IOException e) {
      evt.rejectDrop();
    } catch (UnsupportedFlavorException e) {
      evt.rejectDrop();
    }
  }
Ejemplo n.º 2
0
    public void drop(DropTargetDropEvent e) {
      if (dragSource != null) {
        e.acceptDrop(DnDConstants.ACTION_COPY_OR_MOVE);
        Point p = e.getLocation();
        int targetRow = rowAtPoint(p);

        Object edge =
            graph.insertEdge(
                null,
                null,
                null,
                dragSource.cell,
                JTableRenderer.this.cell,
                "sourceRow=" + sourceRow + ";targetRow=" + targetRow);
        graph.setSelectionCell(edge);

        // System.out.println("clearing drag source");
        dragSource = null;
        e.dropComplete(true);
      } else {
        e.rejectDrop();
      }
    }