Get Image on the System Clipboard in Java
Description
The following code shows how to get Image on the System Clipboard.
Example
//from w w w . ja v a2s . c o m
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.datatransfer.DataFlavor;
import java.awt.datatransfer.Transferable;
public class Main {
public static void main(String[] argv) throws Exception {
Transferable t = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null);
if (t != null && t.isDataFlavorSupported(DataFlavor.imageFlavor)) {
Image img = (Image) t.getTransferData(DataFlavor.imageFlavor);
}
}
}