⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 filedraggesturelistener.java

📁 MyDownloader 是一款使用 http 协议(RFC 1867)用于下载一个或多个文件到本地的简单易用的收费 Java 程序.使用托拽操作,你可以在一个页面内下载多个文件.在下载文件的过程当中
💻 JAVA
字号:
/*
 * Copyright 2007 JavaAtWork All rights reserved.
 * Use is subject to license terms.
 */
package com.javaatwork.mydownloader.listeners;

import java.awt.Cursor;
import java.awt.dnd.DragGestureEvent;
import java.awt.dnd.DragGestureListener;
import java.awt.dnd.DragSource;
import java.io.File;

import com.javaatwork.mydownloader.MyDownloader;

/**
 * This class is responsible for starting the drag as a result
 * of receiving such notification.
 * 
 * @author Johannes Postma
 */
public class FileDragGestureListener implements DragGestureListener {
	
	private MyDownloader applet = null;
		
	/**
	 * Creates a new FilesDragGestureListener
	 * 
	 * @param applet MyDownloader.
	 */
	public FileDragGestureListener(MyDownloader applet) {
		
		this.applet = applet;	
	}
	
	/*
	 * (non-Javadoc)
	 * 
	 * @see java.awt.dnd.DragGestureListener#dragGestureRecognized(java.awt.dnd.DragGestureEvent)
	 */
	public void dragGestureRecognized(DragGestureEvent dge) {
		
		DownloadManager downloadManager = new DownloadManager();
		File [] files = downloadManager.downloadFiles(applet);	
				
		// nothing needs to be dragged
		if (files == null) {
			return;
		}
		
		dge.startDrag(DragSource.DefaultCopyDrop, new DownloadTransferable(files));	
		
		// this method is necessary because when the download is cancelled the defaultcopydrop icon will
		// otherwise be visible
		applet.setCursor(Cursor.getDefaultCursor());	
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -