⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 e639. determining when an item is no longer on the system clipboard.txt

📁 这里面包含了一百多个JAVA源文件
💻 TXT
字号:
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);

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -