Topic: java中能不能监视粘贴板?? |
Print this page |
1.java中能不能监视粘贴板?? | Copy to clipboard |
Posted by: tomh2004 Posted on: 2004-09-16 23:08 java中能不能监视粘贴板??就好像flashget中一样 |
2.Re:java中能不能监视粘贴板?? [Re: tomh2004] | Copy to clipboard |
Posted by: yamakasy Posted on: 2004-09-16 23:51 粘贴事件+处理剪贴板内容 |
3.Re:java中能不能监视粘贴板?? [Re: tomh2004] | Copy to clipboard |
Posted by: tomh2004 Posted on: 2004-09-17 08:46 能不能说一下相关的API |
4.Re:java中能不能监视粘贴板?? [Re: tomh2004] | Copy to clipboard |
Posted by: yamakasy Posted on: 2004-09-17 10:06 推荐你一个网站,不妨自己查查,没时间帮你处理细节。 http://javaalmanac.com/ |
5.Re:java中能不能监视粘贴板?? [Re: tomh2004] | Copy to clipboard |
Posted by: tomh2004 Posted on: 2004-09-17 15:49 ok,谢谢! /** * AWT Sample application * * @author * @version 1.00 04/09/16 * */ import java.awt.datatransfer.Clipboard; import java.awt.datatransfer.ClipboardOwner; import java.awt.datatransfer.Transferable; import java.awt.datatransfer.StringSelection; import java.awt.datatransfer.DataFlavor; import java.awt.datatransfer.UnsupportedFlavorException; import java.awt.Toolkit; import java.io.*; class MyClipboardOwner implements ClipboardOwner{ public void lostOwnership(Clipboard clipboard,Transferable contents) { } 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; } } public class Hello { public static void main(String[] args) { ClipboardOwner owner=new MyClipboardOwner(); StringSelection ss=new StringSelection("A String"); Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss,owner); System.out.println(owner.getClipboard()); } } |
6.Re:java中能不能监视粘贴板?? [Re: tomh2004] | Copy to clipboard |
Posted by: ghuang Posted on: 2004-09-18 13:19 监视? 你指的是不是象加个listener一样,监视粘贴版的活动(例如改变之类的) |
7.Re:java中能不能监视粘贴板?? [Re: tomh2004] | Copy to clipboard |
Posted by: tomh2004 Posted on: 2004-09-18 21:37 是啊,当主窗体激活的时候,能够监视粘贴版的活动 |
8.Re:java中能不能监视粘贴板?? [Re: tomh2004] | Copy to clipboard |
Posted by: littledeer1974 Posted on: 2004-09-19 10:03 主窗体是。。。哪个。。。窗体呀?(不好意思不太明白) |
Powered by Jute Powerful Forum® Version Jute 1.5.6 Ent Copyright © 2002-2021 Cjsdn Team. All Righits Reserved. 闽ICP备05005120号-1 客服电话 18559299278 客服信箱 714923@qq.com 客服QQ 714923 |