我将如何从系统剪贴板粘贴到java中的任意窗口?
我正在制作一个聊天程序,它将粘贴用户输入的文本一定次数,这实际上会在受害者的屏幕上挤满一堆消息。我已经将文本复制到剪贴板上,但我无法弄清楚如何在不使用机器人类的情况下将其粘贴回来,我不想这样做,因为我无法弄清楚如何按命令键mac,所以它不会是多平台的,因为如果有人按下中间的一个键,它可能会做一些完全不同的事情。如果有人可以帮助我使用 Clipboard 类进行粘贴,那就太棒了。我已经在十亿个不同的网站上查找过这个问题,但无法弄清楚。提前致谢! :)
I am making a chat program that will paste the text the user puts in a certain number of times which essentially crowds the victims screen with a bunch of messages. I have already copied the text on the clipboard but I am not able to figure out how to paste it back without using the robot class which I don't want to do because I am not able to figure out how to press the command key for mac so it wouldn't be multi-platform and because if somebody presses a key in the middle it could do something completely different. If anybody can help me use the Clipboard class to paste that would be awesome. I've looked this up on like a billion different sites but can't figure it out. Thanks in advance! :)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
http://www.javapractices.com/topic/TopicAction.do?Id=82
http://www.javapractices.com/topic/TopicAction.do?Id=82
下面展示了如何将文本添加到剪贴板以及如何从剪贴板获取文本。
获得文本后,您可以通过执行以下操作将其添加到文本组件:
The following shows how to add text to the clipboard and how to get text from the clipboard.
Once you have the text you can add it to a text component by doing: