import java.awt.Toolkit; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.Transferable; import java.awt.datatransfer.UnsupportedFlavorException; import java.awt.image.BufferedImage; import java.io.IOException;
public static BufferedImage getSystemImageClipboard() throws IOException, UnsupportedFlavorException{ Transferable t = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null); if (t != null && t.isDataFlavorSupported(DataFlavor.imageFlavor)){ return (BufferedImage)t.getTransferData(DataFlavor.imageFlavor); } else { return null; } }
沒有留言 :
張貼留言