प्रश्न किया गया है (https://community.oracle.com/thread/3934986)JavaFX खींचें && ड्रॉप लक्ष्य फ़ोल्डर पाने के बाद ड्रॉप जावा Oracle समुदाय पर
समस्या:
मैं एक Button
के लिए नीचे दिए गए कोड की स्थापना की है जो यह भरा हुआ है नाम फ़ाइल पथ का प्रतिनिधित्व करता है। इसलिए जब Button
किसी फ़ोल्डर या डेस्कटॉप पर खींचा जाता है (मान लें Windows
में) यह उपयोगकर्ता की ऑपरेटिंग सिस्टम द्वारा प्रतिलिपि बनाई गई है।
मैं लक्ष्य फ़ोल्डर प्राप्त करना चाहता हूं जिस पर ड्रॉप किया गया है।
कोड:
button.setOnDragDetected(event -> {
/* allow copy transfer mode */
Dragboard db = startDragAndDrop(TransferMode.COPY,TransferMode.LINK);
/* put a string on dragboard */
ClipboardContent content = new ClipboardContent();
/*Adding a file into the ClipboardContent*/
content.putFiles(Arrays.asList(new File(getSongPath())));
........//not showing this code....
db.setContent(content);
event.consume();
}
संपादित करें: (29/09/2016)
जब ड्रॉप किया जाता है:
setOnDragDone(d -> {
System.out.println(
"Drag Done,is drop completed?" + d.isDropCompleted() + " , is accepted?" + d.isAccepted());
System.out.println("Accepted Mode:" + d.getAcceptedTransferMode());
System.out.println(" Target:" + d.getTarget() + " Gestoure Target:" + d.getGestureTarget());
});
मैं इस उत्पादन जहां आप देख सकते है कि Gesture Target == null
Drag Done:true , s drop completed?false , is accepted?true
Accepted Mode:COPY
Target:[email protected][styleClass=table-view] Gesture Target:null
Hava इस सवाल पर एक नज़र: http://stackoverflow.com/questions/25488319/how-to-update-progress-of-the-progress- बार-टू-शो-द-प्रोग्रेस-ऑफ-कॉपीिंग-ए-फिल – jns
मैं एक ही समस्या पर फंस गया ... क्या आपको कोई समाधान मिला? – Harald
@ user364044 मैंने इस प्रश्न को ओरेकल जावा समुदाय पर भी पोस्ट किया है और कोई जवाब नहीं है। :( – GOXR3PLUS