views:

67

answers:

1

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.

+2  A: 

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.

Devon_C_Miller
I updated the video driver and checked the JRE. No change. I added the two JVM options mentioned and the problem went away. Thanks for the tip!
Morinar