为什么我们的 Java 应用程序不会在辅助监视器上显示窗口? [英] Why would our Java app not display windows on secondary monitor?

查看:27
本文介绍了为什么我们的 Java 应用程序不会在辅助监视器上显示窗口?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们有一个 Java/Swing 客户端,它已经存在好几年了.当我从 XP 迁移到 Vista(客户端仅在 Windows 上运行)时,我注意到每当在我的辅助监视器上创建一个新窗口(通常是 JFrame 后代)时,该窗口最初显示为空白,即而不是显示正常内容窗户,它只是一块坚实的灰色.如果我然后将该窗口拖到主监视器上,第二个它越过监视器边界,它会正确地绘制自己,我可以将其拖回辅助监视器.如果窗口是在主监视器上创建的,它总是完美地存在.我从来没有在 XP 上遇到过这个问题,只有在 Vista 上.我无法在 Windows 7 上轻松测试它,因为缺少双显示器 Windows 7 机器.

We have a Java/Swing client that's been around for quite a few years. When I moved from XP to Vista (client ONLY runs on Windows), I noticed that whenever a new window is created (usually a JFrame descendant) on my secondary monitor, the window initially shows as blank, i.e. instead of showing the normal contents of the window, it's just a solid block of gray. If I then drag that window onto the primary monitor, the second it crosses the monitor boundary, it draws itself properly and I can drag it back to the secondary monitor. If the window is created on the primary monitor, it always comes into existence perfectly. I NEVER had this problem on XP, only on Vista. I'm unable to easily test it on Windows 7, lacking a dual monitor Windows 7 machine.

有人有任何想法吗?这可能是一个已知的 Java 错误吗?我也在运行最新的 Java 1.6 SDK.

Anybody have any ideas? Is this perhaps a known Java bug? I'm also running the most recent Java 1.6 SDK.

推荐答案

检查视频驱动程序和 JRE 是否是最新的.(可以使用当前的 JDK,但使用旧的 JRE.)

Check that the video driver and the JRE are up to date. (It is possible to have a current JDK, but an old JRE.)

Java 会将缓冲委托给 DirectDraw 和/或 Direct3D.您可以使用以下 JVM 选项禁用此功能:

Java will delegate the buffering to DirectDraw and/or Direct3D. You can disable this with the following JVM options:

  • -Dsun.java2d.d3d=false
  • -Dsun.java2d.noddraw=true

还有其他选项在这里.

如果主显示器位于辅助显示器的右侧,则辅助显示器上的屏幕位置将具有负 X 值.(同样,如果次要位置高于主要位置,则 Y 值将为负.)可能存在未处理负值的代码.

If the primary monitor is to the right of the secondary monitor, the screen positions on the secondary monitor will have negative X values. (Likewise if the secondary is above the primary positions will have negative Y values.) It is possible there is code that is not handling the negative values.

这篇关于为什么我们的 Java 应用程序不会在辅助监视器上显示窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆