Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

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));
frame.getContentPane().add(field);
frame.pack();
frame.setVisible(true);
}
}

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!

Comments

Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Oct 18 2010
Added on Aug 13 2010
3 comments
2,461 views