Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 788
Morinar Avatar asked Aug 30 '10 17:08

Morinar


1 Answers

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.

like image 191
Devon_C_Miller Avatar answered Oct 01 '22 00:10

Devon_C_Miller