• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Drag and Drop problem with Images (*.jpg & *.gif)

 
Anu Sri
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All
Please help me with following problem. I am having a problem with Images needs to be transfer from Explorer to the WebPane. I can able to copy file( mean .doc file and .txt and .html files). But i have to copy oly image file (*.jpg & *.gif) files only. I am just entering what I wrote for files here, Please let me know what I need to modify.

private class DropTargetHandler implements DropTargetListener {

public void drop ( DropTargetDropEvent event ){

Transferable transferable = event.getTransferable();

if( transferable.isDataFlavorSupported( DataFlavor.javaFileListFlavor ) ){
// if ( (DataFlavor.javaFileListFlavor).equals(DataFlavor.imageFlavor))(This I wrote for first image file) {
event.acceptDrop(DnDConstants.ACTION_COPY);

try {
java.util.List fileList = (java.util.List) transferable.
getTransferData(DataFlavor.javaFileListFlavor )

//java.util.List fileList = (java.util.List) transferable.
getTransferData(DataFlavor.imageFlavor);(This is what I wrote for Imagefile by replacing the above)

Iterator iterator = fileList.iterator();

while (iterator.hasNext()) {

File file = (File) iterator.next();
browserPane.goToURL(file.toURL());

}
event.dropComplete(true);
}

After this I did catch exception like that.

PLease let me know what I need to change in the above code for getting ONLY IMAGES (*.gif & *.jpg) HAS TO BE DROPPED.

Thank you
Anu
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24208
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm going to move this to the Swing/AWT forum to see if you can have some better luck over there.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic