📄 filedraggesturelistener.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 + -