这个压缩包里的都是超级经典的java例子
源代码在线查看: clipevt.htm
Determining When an Item Is No Longer on the System Clipboard (Java Developers Almanac Example)
The Java Developers Almanac 1.4
Order this book from Amazon.
google_ad_client = "pub-6001183370374757";
google_ad_width = 120;
google_ad_height = 600;
google_ad_format = "120x600_as";
google_ad_channel = "4777242811";
google_ad_type = "text_image";
google_color_border = "FFFFFF";
google_color_bg = "FFFFFF";
google_color_link = "6666CC";
google_color_url = "6666CC";
google_color_text = "000000";
//-->
Home
>
List of Packages
>
java.awt.datatransfer
[3 examples]
e639. Determining When an Item Is No Longer on the System Clipboard
When an item is set on the system clipboard, it is possible to be
notified when that item is no longer on the clipboard. This is done
by including a clipboard owner object when setting the item.
// This class serves as the clipboard owner.
class MyClipboardOwner implements ClipboardOwner {
// This method is called when this object is no longer
// the owner of the item on the system clipboard.
public void lostOwnership(Clipboard clipboard, Transferable contents) {
// To retrieve the contents, see
// e637 Getting and Setting Text on the System Clipboard
}
}
Here's some code that uses the clipboard owner:
// Create a clipboard owner
ClipboardOwner owner = new MyClipboardOwner();
// Set a string on the system clipboard and include the owner object
StringSelection ss = new StringSelection("A String");
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, owner);
Related Examples
e637.
Getting and Setting Text on the System Clipboard
e638.
Getting and Setting an Image on the System Clipboard
© 2002 Addison-Wesley.