FileDocCategorySizeDatePackage
FileDropper.javaAPI DocExample5215Mon Jan 09 11:02:00 GMT 2006None

FileDropper

public class FileDropper extends Object

Fields Summary
Constructors Summary
Methods Summary
public static voidmain(java.lang.String[] args)

        JFrame frame = new JFrame("Drag and Drop File Hack");
        frame.setDefaultCloseOperation(frame.EXIT_ON_CLOSE);
        
        FileSystemView fsv = FileSystemView.getFileSystemView();
        Icon icon = fsv.getSystemIcon(File.createTempFile("myfile.",".txt"));
		System.out.println("icon = " + icon);
        //ImageIcon iicn = (ImageIcon)icon;
        
        frame.getContentPane().setLayout(new BorderLayout());
        JTextArea text = new JTextArea();

        JLabel label = new JLabel("myfile.txt",icon,SwingConstants.CENTER);
        DragSource ds = DragSource.getDefaultDragSource();
        DragGestureRecognizer dgr = ds.createDefaultDragGestureRecognizer(
            label,
            DnDConstants.ACTION_MOVE,
            new FileDragGestureListener(text));
            
        frame.getContentPane().add("North",label);
        frame.getContentPane().add("Center",text);
        
        frame.pack();
        frame.setSize(400,300);
        frame.setVisible(true);