Java多显示器问题
我正在开发一个应用程序,其中三个显示器配置为一个系统。两个显示器具有不同的显示内容,这是使用 java GraphicsEnvironment
和 GraphicsDevice
类实现的。现在,连接到系统的第三个监视器应该显示前两个监视器(Display0 或 Display1)之一的内容,通过它可以查看操作。 (此监视器的工作方式应与远程访问软件的工作方式类似,例如 vnc 查看器)。
每个图形设备都有自己的 JFrame 要显示,我正在向这些设备显示我的 JComponent,但我对第三个显示器如何处理一无所知。 Java是否提供任何API或机制,以便我可以将一个监视器上的操作显示到另一个监视器上?任何想法/见解都将受到高度赞赏。
问候
妮基
I am developing an application with three monitors configured with one system. Two monitors are having different display contents which is achieved using java GraphicsEnvironment
and GraphicsDevice
classes. Now the third monitor attached to the system is supposed to display the content of one of the first two monitor(either Display0 or Display1) through which the operation could be viewed. (This monitor should work just like how a remote access software works, e.g vnc viewer).
Each graphics device has own JFrame to display, I am displaying my JComponents to these devices, but I am clueless with this third monitor how to handle. Does Java provide any API or mechanism so that I can show the operations on one monitor into another monitor? Any idea/insight will be highly appreciated.
Regards
Nikki
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只读访问并不难。我们将拥有的 2 个 JFrame 称为frameA 和frameB 以及新监视器上的frameC。
您可以将 A 或 B 的内容渲染到 C 中,如下所示:
然后,定期运行此代码:
如果您确实想从 FrameC 控制 FrameA/B,那就有点困难了。我可能会从 java.awt.Robot。 Java2S 有一些演示 Robot 使用的示例。
控制“远程”框架最困难的部分是将框架 C 中的鼠标事件转换为框架 A/B。您需要计算图像的偏移量,然后将其转换回另一个框架的内容窗格。
注意:SwingUtilities 有多种方法可以帮助您翻译坐标。
Read-only access isn't very hard. Let's call the 2 JFrames you have frameA and frameB and the frame on the new monitor frameC.
You can render the contents of A or B into C as follows:
Then, periodically, run this code:
If you actually want to control frameA/B from frameC, that gets a good bit harder. I would probably start with java.awt.Robot. Java2S has some examples demonstrating the use of Robot.
The hardest part of controling the "remote" frame will be translating mouse events in frameC to frameA/B. You'll need to calculate the offset into the image, then translate that back to the content pane of the other frame.
Note: SwingUtilities has several methods to help with translating coordinates.