/Users/lyon/j4p/src/gui/tree/FileListTransferable.java

1    package gui.tree; 
2     
3    import java.awt.datatransfer.DataFlavor; 
4    import java.awt.datatransfer.Transferable; 
5    import java.io.File; 
6    import java.util.ArrayList; 
7    import java.util.List; 
8     
9    public class FileListTransferable implements Transferable { 
10       public FileListTransferable(File[] files) { 
11           fileList = new ArrayList(); 
12           for (int i = 0; i < files.length; i++) { 
13               fileList.add(files[i]); 
14           } 
15       } 
16    
17       // Implementation of the Transferable interface 
18       public DataFlavor[] getTransferDataFlavors() { 
19           return new DataFlavor[]{DataFlavor.javaFileListFlavor}; 
20       } 
21    
22       public boolean isDataFlavorSupported(DataFlavor fl) { 
23           return fl.equals(DataFlavor.javaFileListFlavor); 
24       } 
25    
26       public Object getTransferData(DataFlavor fl) { 
27           if (!isDataFlavorSupported(fl)) { 
28               return null; 
29           } 
30    
31           return fileList; 
32       } 
33    
34       List fileList;      // The list of files 
35   }