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();
}
}}}

