Alert when Losting Clipboard owner
import java.awt.Toolkit;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.ClipboardOwner;
import java.awt.datatransfer.StringSelection;
import java.awt.datatransfer.Transferable;
public class Main {
public static void main(String[] argv) throws Exception {
ClipboardOwner owner = new MyClipboardOwner();
StringSelection ss = new StringSelection("A String");
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, owner);
}
}
class MyClipboardOwner implements ClipboardOwner {
public void lostOwnership(Clipboard clipboard, Transferable contents) {
System.out.println("lost");
}
}
Home
Java Book
Runnable examples
Java Book
Runnable examples
System:
- Copy and paste string to and from System Clipboard
- Copy and paste image to and from System Clipboard
- Alert when Losting Clipboard owner
- System beeper
- Beep by printing the ASCII Bell character to the console
- Total amount of memory in Java virtual machine
- Maximum amount of memory in Java virtual machine
- Free amount of memory in Java Virtual Machine
- Environment variables