Here you can find the source of setClipboardImage(final Image image)
Parameter | Description |
---|---|
image | the specified image to write |
public static void setClipboardImage(final Image image)
//package com.java2s; import java.awt.Image; import java.awt.Toolkit; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.Transferable; import java.awt.datatransfer.UnsupportedFlavorException; import java.io.IOException; public class Main { /**//from w ww . j a v a 2s. c o m * Write the specified image to system clip board. * * @param image * the specified image to write */ public static void setClipboardImage(final Image image) { Transferable trans = new Transferable() { public DataFlavor[] getTransferDataFlavors() { return new DataFlavor[] { DataFlavor.imageFlavor }; } public boolean isDataFlavorSupported(DataFlavor flavor) { return DataFlavor.imageFlavor.equals(flavor); } public Object getTransferData(DataFlavor flavor) throws UnsupportedFlavorException, IOException { if (isDataFlavorSupported(flavor)) return image; throw new UnsupportedFlavorException(flavor); } }; Toolkit.getDefaultToolkit().getSystemClipboard().setContents(trans, null); } }