public void getClipboardsContent() throws Exception {
sClip = Toolkit.getDefaultToolkit().getSystemClipboard();
Transferable tp;
Transferable ts;
StringSelection content = new StringSelection(tf1.getText());
sClip.setContents(content,content);
tp = pClip.getContents(this);
ts = sClip.getContents(this);
// Paste the contents of System clipboard on textfield tf2 while the paste the contents of
// of primary clipboard on textfiled tf3
if ((ts != null) && (ts.isDataFlavorSupported(DataFlavor.stringFlavor))) {
tf2.setBackground(Color.white);
tf2.setForeground(Color.black);
tf2.setText((String) ts.getTransferData(DataFlavor.stringFlavor));
}
if ((tp != null) && (tp.isDataFlavorSupported(DataFlavor.stringFlavor))) {
tf3.setBackground(Color.white);
tf3.setForeground(Color.black);
tf3.setText((String) tp.getTransferData(DataFlavor.stringFlavor));
}
}
IndependenceSwingTest.java 文件源码
java
阅读 29
收藏 0
点赞 0
评论 0
项目:openjdk-jdk10
作者:
评论列表
文章目录