I must copy a image from java application to another graphic application such as photoshot. I think I must paste the image to system clipboard.
I can copy/paste a image by a clipboard made by myself(e.g. Clicpboard clipboard = new Clipboard("MyClicpboard"))). but I have no idea how to do it with system clipboard. below is the exception i can not get rid of:
java.lang.ClassCastException: [I
at sun.awt.windows.WDataTransferer.translateTransferable(WDataTransferer.java:390)
at sun.awt.DataTransferer.translateTransferable(DataTransferer.java:245)
at sun.awt.windows.WClipboard.setContents(WClipboard.java:69)
at Test.<init>(Test.java:40)
at Test.main(Test.java:12)
Re: how to paste image through system clipboard
Dec 5, 2001 5:11 AM
(reply 2
of 7) (In reply to
#1 )
I'm seeing this exception now as well in code that used to work in previous flavors of 1.3. Any ideas? The object appears to get copied but the code always throws on the setContents call. Anyone in the AWT group look at this?
Then call setContents (Transferable t, ClipboardOwner o) where t is not null and o is (but it didn't seem to matter even when I provided and owner, it still threw).
To change this generated comment edit the template variable "typecomment": Window>Preferences>Java>Templates. To enable and disable the creation of type comments go to Window>Preferences>Java>Code Generation.
*/
import java.awt.Image;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
import java.awt.datatransfer.UnsupportedFlavorException;
import java.io.IOException;
Re: how to paste image through system clipboard
Jan 5, 2004 2:45 PM
(reply 7
of 7) (In reply to
#6 )
I had the same problem but was able to fix it when I fixed my custom transferable to report the correct data flavor. See the post before the one with the code for a litte more information.