简体   繁体   English

无法从MAC OSX上的后台Java应用程序复制到剪贴板

[英]Can't copy to a clipboard from a background java application on MAC OSX

We have 2 java applications running on MAC. 我们有2个在MAC上运行的Java应用程序。 One background application sends either a text or image to a clipboard, then the other application grabs that data and paste it in its application. 一个后台应用程序将文本或图像发送到剪贴板,然后另一个应用程序获取该数据并将其粘贴到其应用程序中。

We have this problem when the app copies something on the clipboard, the background app won't be able to update the clipboard until it's UI becomes active. 当应用程序将某些内容复制到剪贴板上时,我们将遇到此问题,后台应用程序将无法更新剪贴板,除非其UI处于活动状态。

Is there work around with this clipboard issue? 此剪贴板问题可以解决吗? This works on Windows and Linux, it seems to be a problem only on MAC. 这在Windows和Linux上都有效,似乎仅在MAC上才是问题。

Don't. 别。

What you are doing is generally referred to as "interprocess communication" . 您所做的通常称为“进程间通信” There are various strategies to accomplish this. 有多种策略可以实现此目的。 One of the more 'correct' approaches, in your cotext of two Java applications, would be to use Java RMI . 在两个Java应用程序的共同背景下,一种更“正确”的方法是使用Java RMI

Doing it in a non-standard, "hackish" manner like you are with the clipboard is more problematic...as you have discovered the hard way. 就像您使用剪贴板一样,以非标准的, “骇人的”方式进行操作更成问题……因为您已经发现了困难的方式。

Even if you did manage to get it running, the possibilities of problems in the future are high. 即使您确实设法使其运行,将来出现问题的可能性也很高。 Eg: Imagine a Windows update changing the behavior of the clipboard--it would break your app on Windows. 例如:假设Windows更新更改了剪贴板的行为-这会破坏Windows上的应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM