Why would our Java app not display windows on secondary monitor?

家住魔仙堡 提交于 2020-01-22 17:46:05

问题


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.

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


回答1:


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 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

There are other options detailed here.

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.



来源:https://stackoverflow.com/questions/3602590/why-would-our-java-app-not-display-windows-on-secondary-monitor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!