The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
October 2001



This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.


How to Drag and Drop jpeg/gig images in java

Posted by Avin Sinanan on October 25, 2001 at 12:42 PM

Hello my name is Avin Sinanan and I currently a student of the University of the West Indies. I am crrently doing my Final year Project which is Java based and i have a question about Drag And drop(am actually suppose to make a program resemlbing PSPICE) and i was wodering if you can help me with this question.

Ok i can do Drag and Drop with text. Thats easy. Actually i got the code at and well i modified it and well now i understand it. The problem is that i need to Drag and Drop Images from one Panel to another Panel.

I can get the images to appear in the panels ( actully am using two GIF pictues) one in each pnael. But am having trouble Draging and dropping the images.

Now i actually tried creating a mime to support the images. I actually tried this :

DataFlavor imageFlavor = new DataFlavor("ImageIcon/gif" ,"Image");

This did not work.

Then i went to

and i learnt that some clipboards do not support images such as gif and jprg and that i had to make my own InputStream and at it to my FlavourMap properties. How do i make an inputstream and add it to FLavourmap properties. Is that my problem or is my problem somewhere else.

I even tried the inputstream provied at the

and added it to the file but that didn't wrok either.When i complied my file it jus said that it didn't recognise the class provided by

I provided the code for my program below.You will need two gif files to run.. if you have time. the name of the 2 gif files are arrow.gif and arrow2.gif

Can someone please help me?


Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us