Skip to Main Content

Java SE (Java Platform, Standard Edition)


For appeals, questions and feedback, please email

Java Drag and Drop on Windows Vista/7

843807Aug 13 2010 — edited Sep 20 2010
hi! im trying to get simple drag and drop behaviour on windows vista and windows 7 but it seems it doesnt work. im trying to drag an image file into a JFormattedTextField that has default DnD behaviour so i can get the path on the field. im using a very simple piece of code. it works on ubuntu linux, but it seems that the same code just dont work on windows 7 and windows vista. heres the code

public class DnDTest{
public static void main(String[] args){
JFrame frame = new JFrame();
JFormattedTextField field = new JFormattedTextField();
field.setPreferredSize(new Dimension(100,30));

i run it, then drag an image from windows desktop on the field component but the drop doesnt happen. when i do the same on ubuntu it works. im running it from netbeans 6.9 and using jdk1.6_20. thanks in advance!
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Oct 18 2010
Added on Aug 13 2010