Ejemplo n.º 1
0
 private void initialize() {
   // install drag n drop support
   dragSource = DragSource.getDefaultDragSource();
   dgRecognizer =
       dragSource.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_MOVE, this);
   // don't act on right mouse button
   dgRecognizer.setSourceActions(
       dgRecognizer.getSourceActions() & ~InputEvent.BUTTON3_MASK & ~InputEvent.BUTTON2_MASK);
   new DropTarget(this, new CDropTargetListener());
 }
Ejemplo n.º 2
0
  /** convenience routine for setting up drag and drop */
  private void setupDnD() {

    // gesture recognizer establishes what action starts the dnd

    DragGestureRecognizer dgr =
        dragSource.createDefaultDragGestureRecognizer(
            this, // DragSource
            DnDConstants.ACTION_COPY, // specifies valid actions
            this // DragGestureListener
            );

    /*
     * Eliminates right mouse clicks as valid actions - useful especially if
     * you implement a JPopupMenu for the JTree
     */
    dgr.setSourceActions(dgr.getSourceActions() & ~InputEvent.BUTTON3_MASK);
  }