Java识别超过2个监视器

发布于 2024-10-17 08:01:25 字数 564 浏览 9 评论 0原文

我正在开发一个基于 Java swing 的应用程序,它将有 3 个不同的主 JFrame,并且每个 JFrame 都必须显示在系统中存在的三个显示监视器之一上。此外,应用程序将能够在特定显示监视器断开连接或重新连接时发出警报。

每个主 JFrame 必须显示在特定的显示屏上。这是由于这些监视器的放置位置决定的。更像是销售点场景,其中一台显示器可以为销售人员显示内容,另一台显示器可以为客户显示内容,另一台显示器可以为保安人员显示内容。

现在的主要问题是如何知道哪个显示器是哪个。我通过从 Java 中调用 VBScript 获取每个监视器的序列号解决了这个问题。

但还有一个问题是如何在Java中映射监视器的序列号信息。在Java中,我可以获得与每个监视器相对应的是一个java.awt.GraphicsDevice实例,我不知道如何将序列号信息映射到此实例,因为拥有这些java.awt.GraphicsDevice实例的唯一方法是GraphicsEnvironment。 getLocalGraphicsEnvironment().getScreenDevices() 并且此函数不能确保每次调用该函数时都会按特定顺序返回设备。

期待中的感谢

I am developing an Java swing based application which will 3 distinct main JFrames and each one of these will have to be displayed on one of the three display-monitors present in the system. Moreover application is going to have capability to alertif a particular display-monitor gone disconnected or reconnecetd.

Each main-JFrame must be displayed on a specific display-screen. This is due to the place where these monitors are going to be located. More like a point of sale scenario where one monitor can show things for sale-person and other for client and other for a security person.

Now the main issue is how to know which monitor is which. I solved this issue by getting serial-no of each monitor by calling a VBScript from within Java.

But still another problem is how map serial-no information of the monitor in Java. In Java what I can get corresponding to each monitor is a java.awt.GraphicsDevice instance and I have no idea how I can map serial-no information to this as the only way to have these instances of java.awt.GraphicsDevice is GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices() and this function does not ensure that it will return the devices in a sepecific sequence, each time the function is called.

Thanking in anticipation

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

烟燃烟灭 2024-10-24 08:01:25

Java 通过 GraphicsEnvironment 和 GraphicsDevice 对象支持多个监视器。有关详细信息,请检查 GraphicsDevice javadoc。

Java supports multiple monitors via a GraphicsEnvironment and GraphicsDevice objects. Check the GraphicsDevice javadoc for more info.

梦断已成空 2024-10-24 08:01:25

是否GraphicsDevice.getIDString() 方法会为您提供一个可以与序列号进行比较的稳定值吗?如果是这样,您可以将所有识别的序列号写入属性文件,并在每次程序启动时进行比较(如果 ID 还不是序列号)。该属性文件还可以存储每个显示器的位置(左、中、右或上、中、下等)。

如果您无法确定 id 和序列号之间的对应关系,则可以在任何时候触发“显示器设置例程”您看到的显示 ID 不在您的属性文件中。

该例程将提示用户确认显示器型号并输入每个显示器的位置(考虑 Win、OS X、Linux 等中的显示器方向设置)。如果您可以将小部件绘制到特定的显示器上,您应该能够收集此信息。此外,如果用户重新排列其显示器的物理位置(可能交换两个显示器的位置),那么他们可以手动执行此例程。

Does the GraphicsDevice.getIDString() method give you a stable value that you can compare against the serial numbers? If so, you can write all identified serial numbers to a property file, and do a comparison each time your program starts (if the ID isn't already the serial num). This property file could also store the position of each display (left, center, right or top, middle, bottom, etc)

If you cannot determine the correspondance between the id and the serial number, you could trigger a 'display setup routine' whenever you see an display id that is not in your properties file.

This routine would prompt the user to confirm the display model number and enter the position of each display (consider the display orientation settings in Win,OS X, Linux etc). If you can draw widgets to a specific display, you should be able to collect this information. Also, if the user rearranges the physical position of their displays (perhaps swapping the position of two displays), then they could manually execute this routine.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文