Java 8 DragSource - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 DragSource class.

This code example shows how to use the following methods:createDefaultDragGestureRecognizer
        if (model == null) {
            throw new IllegalArgumentException("model must not be null");
        } 
        //this.setModel(model); 
 
        src = new DragSource();
        src.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_MOVE, this);
 
        tgt = new DropTarget(this, this);
 
        movingItems = false;
        overIndex = -1;
    } 
 
    @SuppressWarnings("unchecked") 
    @Override 
    public DnDListModel<T> getModel() { 
        return (DnDListModel<T>) super.getModel(); 
    } 
    /** 
5
CodeRank
This code example shows how to use the following methods:createDefaultDragGestureRecognizer
     *  
     */ 
     
    public MusicList( int dndType ) {
 
        dragSource = new DragSource();
        dragSource.createDefaultDragGestureRecognizer( this, dndType, this );
 
    } 
     
    public void dragDropEnd( DragSourceDropEvent evt ) {}
    public void dragExit( DragSourceEvent evt ) {}
    public void dropActionChanged( DragSourceDragEvent evt ) {}
    public void dragOver( DragSourceDragEvent evt ) {}
    public void dragEnter( DragSourceDragEvent evt ) {}
 
    /** 
     *  a drag gesture has been recognised, passes the selected music 
     *  item to the transfar handler 
     *  
5
CodeRank
This code example shows how to use the following methods:createDefaultDragGestureRecognizer
     */ 
 
    public DNDList(ListModel dataModel) {
        super(dataModel);
        dropTarget = new DropTarget(this, this);
        dragSource = new DragSource();
        dragSource.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_MOVE, this);
    } 
 
    /** 
     * is invoked when you are dragging over the DropSite 
     */ 
 
    public void dragEnter(DropTargetDragEvent event) {
 
        // debug messages for diagnostics 
        System.out.println("dragEnter");
        event.acceptDrag(DnDConstants.ACTION_MOVE);
    } 
 
5
CodeRank
This code example shows how to use the following methods:createDefaultDragGestureRecognizer
    } 
 
    private TableTransferHandler( JTable table, FolderPanel.FolderModel model, int action ) {
        this.table = table;
        this.sourceModel = model;
        dragSource = new DragSource();
        dragSource.createDefaultDragGestureRecognizer( table, action, this );
//    dt = new DropTarget(table, this); 
    } 
 
    public void dragDropEnd( DragSourceDropEvent dsde ) {
        if( dsde.getDropSuccess() && dsde.getDropAction() == DnDConstants.ACTION_MOVE ) {
            sourceModel.fireTableDataChanged();
        } 
    } 
 
    public final void dragEnter( DragSourceDragEvent dsde ) {
        int action = dsde.getDropAction();
        if( action == DnDConstants.ACTION_COPY ) {
            dsde.getDragSourceContext().setCursor( DragSource.DefaultCopyDrop );
5
CodeRank
This code example shows how to use the following methods:addDragSourceMotionListener, createDefaultDragGestureRecognizer
            removeFocusListener(this);
        } 
        addFocusListener(this);
        this.setFocusable(true);
        this.addMouseListener(this);
        dragSource = new DragSource();
        dragSource.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY, this);
        dragSource.addDragSourceMotionListener(this);
    } 
 
    public void reBuildThumbnail(MediaSeries.MEDIA_POSITION position) {
        reBuildThumbnail(null, position);
    } 
 
    public void reBuildThumbnail() { 
        reBuildThumbnail(null, mediaPosition);
    } 
 
    public synchronized void reBuildThumbnail(File file, MediaSeries.MEDIA_POSITION position) {
        Object media = series.getMedia(position, null, null);
5
CodeRank
This code example shows how to use the following methods:createDefaultDragGestureRecognizer
    private TreeDropTarget dt;
 
    public TreeDragSource(JTree tree, int actions, ProjectController eventController) {
        sourceTree = tree;
        this.eventController = eventController;
        source = new DragSource();
        recognizer = source.createDefaultDragGestureRecognizer(sourceTree, actions, this);
    } 
 
    /* 
     * Drag Gesture Handler 
     */ 
    public void dragGestureRecognized(DragGestureEvent dge) {
        TreePath path = sourceTree.getSelectionPath();
        if ((path == null) || (path.getPathCount() <= 1)) {
            return; 
        } 
        dt = new TreeDropTarget(sourceTree, eventController, path);
        source.startDrag(dge, DragSource.DefaultLinkDrop, dt, this);
    } 
5
CodeRank
This code example shows how to use the following methods:createDefaultDragGestureRecognizer
 
    /** 
     * Creates a new JTree that supports dragging tree nodes. 
     **/ 
    public DraggableTree() { 
        fDragSource.createDefaultDragGestureRecognizer(
                this, DnDConstants.ACTION_COPY_OR_MOVE, this);
    } 
 
    /** 
     * Creates a new JTree that supports dragging tree nodes.  The specified TreeModel 
     * is used as the data model. 
     * 
     * @param	model	the TreeModel to use as the data model 
     **/ 
    public DraggableTree(TreeModel model) {
        super(model);
 
        fDragSource.createDefaultDragGestureRecognizer(
                this, DnDConstants.ACTION_COPY_OR_MOVE, this);
4
CodeRank
This code example shows how to use the following methods:startDrag
			MouseEvent evt = (MouseEvent)in;
			boolean isLeftMouse = SwingUtilities.isLeftMouseButton(evt);
 
		    if (isLeftMouse && !evt.isAltDown()) {
		    	this.requestFocus();
				dragSource.startDrag(e, DragSource.DefaultCopyDrop, this, this);
			} 
		} 
	} 
 
    /** 
     * This method is invoked to signify that the Drag and Drop 
     * operation is complete. The getDropSuccess() method of 
     * the <code>DragSourceDropEvent</code> can be used to 
     * determine the termination state. The getDropAction() method 
     * returns the operation that the drop site selected 
     * to apply to the Drop operation. Once this method is complete, the 
     * current <code>DragSourceContext</code> and 
     * associated resources become invalid. 
	 * HERE THE METHOD DOES NOTHING. 
3
CodeRank
This code example shows how to use the following methods:startDrag
			boolean isLeftMouse = SwingUtilities.isLeftMouseButton(evt);
 
		    if (isLeftMouse && !evt.isAltDown()) {
				StringSelection text = new StringSelection(sIdentifier);
				this.requestFocus();
				dragSource.startDrag(e, DragSource.DefaultCopyDrop, text, this);
			} 
		} 
	} 
 
    /** 
     * This method is invoked to signify that the Drag and Drop 
     * operation is complete. The getDropSuccess() method of 
     * the <code>DragSourceDropEvent</code> can be used to 
     * determine the termination state. The getDropAction() method 
     * returns the operation that the drop site selected 
     * to apply to the Drop operation. Once this method is complete, the 
     * current <code>DragSourceContext</code> and 
     * associated resources become invalid. 
	 * HERE THE METHOD DOES NOTHING. 
3
CodeRank
This code example shows how to use the following methods:createDefaultDragGestureRecognizer
 
    /** 
     * Creates an Instance of the Droppable Frame. 
     */ 
    protected DroppableFrame() { 
        dragSource.createDefaultDragGestureRecognizer(this, DnDConstants.ACTION_COPY_OR_MOVE, this);
    } 
 
    public void dragDropEnd(DragSourceDropEvent DragSourceDropEvent) {
    } 
 
    public void dragEnter(DragSourceDragEvent DragSourceDragEvent) {
    } 
 
    public void dragExit(DragSourceEvent DragSourceEvent) {
    } 
 
    public void dragOver(DragSourceDragEvent DragSourceDragEvent) {
    } 
 
3
CodeRank
See Code Examples for Java 8 DragSource Methods: