package clipboard;
import java.awt.*;
import java.awt.datatransfer.*;
public class CopyExample implements ClipboardOwner {
private Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
private void copy(){
String data = "ABC\tあいうえお\t123\n" + "DEF\tかきくけこ\t456\n";
StringSelection contents = new StringSelection(data);
clipboard.setContents(contents, this);
}
public void lostOwnership(Clipboard clipboard, Transferable contents) {
System.out.println("Clipboard contents replaced");
}
public static void main(String[] args){
CopyExample my = new CopyExample();
my.copy();
}
}
|