Forum Stats

  • 3,751,328 Users
  • 2,250,341 Discussions
  • 7,867,384 Comments

Discussions

Get JavaFX Drag and Drop target Folder

GoXR3Plus
GoXR3Plus Member Posts: 3
edited Sep 23, 2016 8:27PM in JavaFX 2.0 and Later

A container with a lot of buttons exist,where each button has a name which represents an absolute file path.So when the button is dragged to a folder or desktop(let's say in Windows) it is copied by user's Operating System:(Code)

<span class="pln">button</span><span class="pun">.</span><span class="pln">setOnDragDetected</span><span class="pun">(</span><span class="pln">event </span><span class="pun">-></span><span class="pln"> </span><span class="pun">{</span><span class="pln"><br/><br/>   </span><span class="com">/* allow copy transfer mode */</span><span class="pln"><br/>   </span><span class="typ">Dragboard</span><span class="pln"> db </span><span class="pun">=</span><span class="pln">  startDragAndDrop</span><span class="pun">(</span><span class="typ">TransferMode</span><span class="pun">.</span><span class="pln">COPY</span><span class="pun">,</span><span class="typ">TransferMode</span><span class="pun">.</span><span class="pln">LINK</span><span class="pun">);</span><span class="pln"><br/><br/>   </span><span class="com">/* put a string on dragboard */</span><span class="pln"><br/>   </span><span class="typ">ClipboardContent</span><span class="pln"> content </span><span class="pun">=</span><span class="pln"> </span><span class="kwd">new</span><span class="pln"> </span><span class="typ">ClipboardContent</span><span class="pun">();</span><span class="pln"><br/><br/>   </span><span class="com">/*Adding a file into the ClipboardContent*/</span><span class="pln"><br/>  content</span><span class="pun">.</span><span class="pln">putFiles</span><span class="pun">(</span><span class="typ">Arrays</span><span class="pun">.</span><span class="pln">asList</span><span class="pun">(</span><span class="kwd">new</span><span class="pln"> </span><span class="typ">File</span><span class="pun">(</span><span class="pln">getSongPath</span><span class="pun">())));</span><span class="pln"><br/><br/>   </span><span class="pun">........</span><span class="pln"><br/><br/>  db</span><span class="pun">.</span><span class="pln">setContent</span><span class="pun">(</span><span class="pln">content</span><span class="pun">);</span><span class="pln"><br/><br/>  event</span><span class="pun">.</span><span class="pln">consume</span><span class="pun">();</span><span class="pln"><br/><br/>   </span><span class="pun">}</span>


The problem:

What i want is when the drop is done to get the folder where the file|files have been dropped..so i can make a progress bar for big files..Here says that it can be done but when i try to get GestureTarget it is null.

Tagged:

Answers

This discussion has been closed.