I read FileTreeDragSource
Can I get file path from Swing to explorer. Not explorer -> Swing!!
Swing -> explorer I wanna get path with explorer
I read FileTreeDragSource
Can I get file path from Swing to explorer. Not explorer -> Swing!!
Swing -> explorer I wanna get path with explorer
Java's DnD support does allow you to drag things out of a Java application into a native one, but I think that it's limited to text and only alows target components which will accept text, like the address bar in a browser.
If the explorer address bar does not accept text from a drag and drop, you could always add a menu option to your application to "Open in Explorer" which just launches a new Explorer process with the file path as a parameter.
Use this as your Transferable and you should be golden!
public class FileList extends Vector<File> implements Transferable {
final static int FILE = 0;
DataFlavor flavors[] = {DataFlavor.javaFileListFlavor};
public FileList(File file) {addElement(file);}
public synchronized DataFlavor[] getTransferDataFlavors() {return flavors;}
public boolean isDataFlavorSupported(DataFlavor flavor) {
return flavor.equals(flavors[FILE]);
}
public synchronized Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException {
if (flavor.equals(flavors[FILE])) return this;
else throw new UnsupportedFlavorException(flavor);
}
}