We’re moving our forums to a new platform.

You can still browse and search existing topics, but you can no longer create new topics or post replies.

For questions, technical issues, or feature requests, please don’t hesitate to contact our support team at support@advancedinstaller.com.

Thank you for your understanding!

olegar
Posts: 2
Joined: Fri Aug 07, 2015 10:29 pm

Drag and drop of files not working

Hello,

I have a Java Swt application which accepts files dragged and dropped from the outside (eg. Windows Explorer).
However, when running the installed version, created with Advanced Installer 12.2.1, the drop onto the app window is disabled.
A black crossed circle icon is displayed when dragging a file over app window, as opposed to the expected drop target cursor with a plus symbol and a dashed rectangle.
When I manually created a cmd file in the installed directory, which runs java with the bundled JRE, classpath etc., drop is working fine.
So it appears like an issue with the EXE starter generated by Advanced Installer.
Please let me know how to enable drag'n'drop of files.
Thanks!

Sample code which reproduces the issue:

Code: Select all

import org.eclipse.swt.dnd.DND;
import org.eclipse.swt.dnd.DropTarget;
import org.eclipse.swt.dnd.DropTargetEvent;
import org.eclipse.swt.dnd.DropTargetListener;
import org.eclipse.swt.dnd.FileTransfer;
import org.eclipse.swt.dnd.TextTransfer;
import org.eclipse.swt.dnd.Transfer;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;

public class FileDrop {

	public static void main(String[] args) {
		Display display = Display.getDefault();
		Shell sh = new Shell(display);

		DropTarget droptarget = new DropTarget(sh, DND.DROP_MOVE
				| DND.DROP_COPY | DND.DROP_DEFAULT | DND.DROP_LINK);

		final FileTransfer fileTransfer = FileTransfer.getInstance();
		final TextTransfer textTransfer = TextTransfer.getInstance();
		droptarget.setTransfer(new Transfer[] { textTransfer, fileTransfer });
		droptarget.addDropListener(new DropTargetListener() {

			public void dragEnter(DropTargetEvent e) {
				e.detail = DND.DROP_COPY;
			}

			public void dragOver(DropTargetEvent e) {
			}

			public void dragOperationChanged(DropTargetEvent e) {
			}

			public void dragLeave(DropTargetEvent event) {
			}

			public void dropAccept(DropTargetEvent event) {
			}

			public void drop(DropTargetEvent e) {
			}
		});

		sh.open();
		while (!sh.isDisposed()) {
			if (!display.readAndDispatch())
				display.sleep();
		}
		display.dispose();
	}
}
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Drag and drop of files not working

Hello and welcome to our forums,

I've tested the scenario (after building a JAR file using your posted java code), but I cannot replicate the behavior. The drag and drop mechanism works the same way in both cases: when launching the JAR directly and when launching the JAR through our EXE java product.

Here it is attached a sample created with version 12.3.1 of Advanced Installer. Can you please download and test it on your side and let us know it this works as expected?

All the best
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube
olegar
Posts: 2
Joined: Fri Aug 07, 2015 10:29 pm

Re: Drag and drop of files not working

Hi Daniel,

Thank you so much! I was able to fix the issue elsewhere in my code (unrelated to Advanced Installer). I appreciate your help.

Thanks,
Oleg
Daniel
Posts: 8283
Joined: Mon Apr 02, 2012 1:11 pm
Contact: Website

Re: Drag and drop of files not working

You're always welcome Oleg.

I'm glad you got all sorted.

All the best,
Daniel
Daniel Radu - Advanced Installer Team
Follow us: Twitter - Facebook - YouTube

Return to “Common Problems”