This examples defines methods for getting and setting text on the system clipboard.

    // If a string is on the system clipboard, this method returns it;
// otherwise it returns null.
public static String getClipboard() {
Transferable t = Toolkit.getDefaultToolkit().getSystemClipboard().getContents(null); try {
if (t != null && t.isDataFlavorSupported(DataFlavor.stringFlavor)) {
String text = (String)t.getTransferData(DataFlavor.stringFlavor);
return text;
}
} catch (UnsupportedFlavorException e) {
} catch (IOException e) {
}
return null;
} // This method writes a string to the system clipboard.
// otherwise it returns null.
public static void setClipboard(String str) {
StringSelection ss = new StringSelection(str);
Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, null);
}
Related Examples

e637. 向剪切板获取和粘贴文本的更多相关文章

  1. e638. 向剪切板获取和粘贴图像

    // If an image is on the system clipboard, this method returns it; // otherwise it returns null. pub ...

  2. 重新想象 Windows 8 Store Apps (40) - 剪切板: 复制/粘贴文本, html, 图片, 文件

    [源码下载] 重新想象 Windows 8 Store Apps (40) - 剪切板: 复制/粘贴文本, html, 图片, 文件 作者:webabcd 介绍重新想象 Windows 8 Store ...

  3. 剪切板 复制文本 ClipboardManager

    代码 public class MainActivity extends ListActivity {     private EditText tv_info;     private Clipbo ...

  4. 背水一战 Windows 10 (102) - 应用间通信: 剪切板

    [源码下载] 背水一战 Windows 10 (102) - 应用间通信: 剪切板 作者:webabcd 介绍背水一战 Windows 10 之 应用间通信 剪切板 - 基础, 复制/粘贴 text ...

  5. js实现复制内容到剪切板,兼容pc和手机端,支持Safari浏览器

    Javascript原生有一些事件:copy.paste.cut, 这些事件可以作用的目标元素: 能获得焦点的元素 (如contentEditable内容能编辑或者可以选中的元素),或者是<bo ...

  6. [.NET开发] C#实现剪切板功能

    C#剪切板 Clipboard类 我们现在先来看一下官方文档的介绍 位于:System.Windows.Forms 命名空间下 Provides methods to place data on an ...

  7. C#剪切板

    C#剪切板 Clipboard类 我们现在先来看一下官方文档的介绍 位于:System.Windows.Forms 命名空间下 Provides methods to place data on an ...

  8. C#操作剪切板(Clipboard)

    剪切板是Windows系统提供的功能,从我最早接触到的Windows 3.2版本开始,就一直带着了.以前使用C++的时候,是直接使用Windows API对其进行操作的,到了.NET下,在WinFor ...

  9. [转载]3.5 UiPath对剪切板的介绍和使用

    一.剪切板操作的介绍 模拟用户使用剪切板操作的一种行为: 例如使用设置剪切板(SettoClipboard),从剪切板获取(GetfromClipboard)的操作 二.剪切板相关操作在UiPath中 ...

随机推荐

  1. 转 MySQL中的行级锁,表级锁,页级锁

      对mysql乐观锁.悲观锁.共享锁.排它锁.行锁.表锁概念的理解 转载. https://blog.csdn.net/puhaiyang/article/details/72284702 实验环境 ...

  2. mysql-5.7中innodb_buffer_pool页面淘汰算法

    一. 什么是innodb_buffer_pool: innodb_buffer_pool是一块内存区域,innodb用它来缓存数据,索引,undo,change buffer ... : 这块区域又被 ...

  3. Spring的三种注入方式(Setter、构造函数和自动注入)

    一.Setter注入 这里我是希望在Student.java中调用Course.java中的内容. public class Course { public String name = "数 ...

  4. Jenkins 使用学习笔记

    3.1    Jenkins安装    2 3.1.1    Jenkins下载    2 3.1.2    Jenkins 安装    2 3.1.3    Jenkins 目录结构    3 3. ...

  5. Vagrant安装指南

    ubuntu的易用性很高,安装很简单,颜值也高,但是我工作中经常使用centos,我希望我的笔记本也是centos,但是,centos颜值太低,配置文件很复杂,不想弄这个太麻烦,于是,我想到了Vagr ...

  6. openvpn证书吊销

    声明变量source ./vars使用revoke-full命令吊销客户端证书./revoke-full client-name(common name)命令执行后,我们能在keys目录中找到一个文件 ...

  7. 使用VMware安装CentOS7步骤详情

    准备资料: CentOS-7-x86_64-Everything-1611 点击下载CentOS 对,资料就这些 第一步.  点击文件  再点击新建虚拟机 第二步 .点击完新建虚拟机之后会跳出一个窗口 ...

  8. 基于Django的独立运行python脚本开发

    Django框架很方便,比如其方便的ORM,如果写基于Django的独立运行脚本,主要在脚本前面加上以下代码: import sys,os,django sys.path.append(os.path ...

  9. JAVA calling convention

    http://stackoverflow.com/questions/28126082/where-does-the-jit-compiled-code-reside https://wiki.ope ...

  10. CString转char * ,string

    CString头文件#include <afx.h> string头文件#include <string.h> 1.CString转char * CString cstr; c ...