Problem with getting image from clipboard- get "failed to get drop data"

I am trying to get an image from the clipboard through Copy command. What happens is when I do Image image = (Image)clipboardContents.getTransferData(DataFlavor.imageFlavor);

I get "java.io.IOException: failed to get drop data" . The image is obviously null and nothing I could do after that. I looked at the API and it says the data "is not there" anymore so that's why i get the nullpointer and IOException. The image itself is 4448X8960 in dimension and I am pretty sure the physical size doesn't matter (have opened files much bigger than this). Any help? Thanks!

Here is the code snipett

Toolkit kit = Toolkit.getDefaultToolkit();

final Clipboard clipboard =

kit.getSystemClipboard();

public Image getPastedImage(){

Transferable clipData =

clipboard.getContents(clipboard);

if (clipData !=null){

if (clipData.isDataFlavorSupported (DataFlavor.imageFlavor)){

Image image=null;

try{

image = (Image)clipData.getTransferData(DataFlavor.imageFlavor);

}catch (UnsupportedFlavorException e){

// TODO Auto-generated catch block

e.printStackTrace();

}catch (IOException e){

// TODO Auto-generated catch block

e.printStackTrace();

}

}}}

[1952 byte] By [shaselaia] at [2007-11-27 11:05:53]
# 1

does anyone know? please help... i followed the code format and am really stuck on how to get the picture. This error is especially weird because if it is a standalone code it works fine but when i use the exact method inside a project with other functions i get the error... please help! thanks

shaselaia at 2007-7-29 13:11:40 > top of Java-index,Desktop,Core GUI APIs...
# 2

> This error is especially weird because if it is a standalone code it works fine but when i use the exact method inside a project with other functions i get the error

Well then you should work on the codes in your project and see which is causing this function on the work, since it works fine in a seperate application. We haven't seen your code and wont know which method may be the src of your problems. [Dont, however, post your entire code, it is not necessary]

Work it out step by step, and you should be able to find the src of the problem.

ICE

icewalker2ga at 2007-7-29 13:11:40 > top of Java-index,Desktop,Core GUI APIs...
# 3

Do you know what "failed to get drop data" means? Like what would be the cause of the error? I copy pasted the code and put in same method as the bigger project and it gets called fine - it just that the line "

(Image)clipData.getTransferData(DataFlavor.imageFlavor);"

returns null and the above error instead of an image. The setup is the same, the call to method is the same (just source is different) but the line above gets me wrong results... i really don't get why.. could it be memory issue? i set 900MB for memory so it should be enough.... i am really lost on this problem...

thanks

shaselaia at 2007-7-29 13:11:40 > top of Java-index,Desktop,Core GUI APIs...
# 4

> Do you know what "failed to get drop data" means?

You might want to take a look at the Java source code in src.zip, it probably contains the Sun code that generates this error code.

ChuckBinga at 2007-7-29 13:11:40 > top of Java-index,Desktop,Core GUI APIs...