Package java.awt.dnd

Examples of java.awt.dnd.DragSource


            else {
                ghost.returnToOrigin();
            }
            ghost = null;
        }
        DragSource src = e.getDragSourceContext().getDragSource();
        src.removeDragSourceMotionListener(this);
        moved = false;
    }
View Full Code Here


    private static void activateDragAndDrop() {
      if(isDnDActive) {
        return;
      }
      isDnDActive = true;
      DragSource dragSource = DragSource.getDefaultDragSource();
      DragSourceAdapter dragSourceListener = new DragSourceAdapter() {
        @Override
        public void dragEnter(DragSourceDragEvent dsde) {
          processDragSourceEvent(dsde);
        }
        @Override
        public void dragMouseMoved(DragSourceDragEvent dsde) {
          processDragSourceEvent(dsde);
        }
        private void processDragSourceEvent(DragSourceDragEvent dsde) {
          if(dndHandler != null) {
            return;
          }
          dndHandler = new DnDHandler();
          List<NativeComponent> nativeComponentList = new ArrayList<NativeComponent>();
          for(NativeComponent nativeComponent: getNativeComponents()) {
            DropTarget dropTarget = nativeComponent.getDropTarget();
            if(dropTarget != null && dropTarget.isActive()) {
              nativeComponentList.add(nativeComponent);
            }
          }
          SWTNativeComponent[] nativeComponents = nativeComponentList.toArray(new SWTNativeComponent[0]);
          boolean[] wereEnabled = new boolean[nativeComponents.length];
          for(int i=0; i<nativeComponents.length; i++) {
            SWTNativeComponent nativeComponent = nativeComponents[i];
            wereEnabled[i] = nativeComponent.isControlParentEnabled;
            nativeComponent.setControlParentEnabled(false, false);
          }
          dndHandler.nativeComponents = nativeComponents;
          dndHandler.wereEnabled = wereEnabled;
        }
        @Override
        public void dragDropEnd(DragSourceDropEvent dsde) {
          if(dndHandler == null) {
            return;
          }
          SWTNativeComponent[] nativeComponents = dndHandler.nativeComponents;
          boolean[] wereEnabled = dndHandler.wereEnabled;
          for(int i=0; i<nativeComponents.length; i++) {
            SWTNativeComponent nativeComponent = nativeComponents[i];
            if(wereEnabled[i]) {
              nativeComponent.setControlParentEnabled(true, false);
            }
          }
          dndHandler = null;
        }
      };
      dragSource.addDragSourceMotionListener(dragSourceListener);
      dragSource.addDragSourceListener(dragSourceListener);
    }
View Full Code Here

TOP

Related Classes of java.awt.dnd.DragSource

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.