Java examples for Native OS:Clipboard
set Clipboard Image
//package com.java2s; import java.awt.*; import java.awt.datatransfer.*; import java.io.IOException; public class Main { public static void setClipboardImage(final Image image) { Transferable trans = new Transferable() { public DataFlavor[] getTransferDataFlavors() { return new DataFlavor[] { DataFlavor.imageFlavor }; }//ww w. jav a2 s. c o m 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); } }