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);
    }
  }
}




















Home »
  Java Tutorial »
    Development »




Java Algorithms
Java Clipboard
Java Compiler
Java Desktop
Java Virtual Machine
Java Math
OS
Random
Java Robot
Java RuntimeMXBean
Java Timer
Java UUID
Java Internationalization