Java2D Dual Monitor Bug?

Could someone please confirm this for me?

I’ve been writing my game in Java, using Java2D, and today decided to run it on my laptop machine at work to see how well it would do. Everything seems to run fine, until I move the window more than halfway into my second monitor (my desktop is set to “extend” onto the second monitor), at which point, the graphics freeze on the section of the window that is on the second monitor (but oddly continue on the part that is still on the first monitor). This is an odd bug to say the least, and I’m not sure if this would be a Java2D bug, or an Nvidia driver bug (or both?).

Here’s my setup details that I think pertain:
A dell latitude D800 laptop (which is also the first monitor, set at 1680x1050 resolution)
A dell sedondary monitor (17" LCD, set at 1280x1024 resolution)
Nvidia 5650 Geforce chip
Latest Dell drivers for the Nvidia chip (I tried the reference drivers, but they were buggy on the system).
Java 5.0 (yeah, 1.5 - but I figure I better start calling it by the same thing as Sun now)

It could just be my setup, but I’m curious as to whether or not it occurs on other dual-monitor systems.

I run a lot of Java2d On a dual monitor setup. ATI gfxthough. No bugs of the kind you have but rendering gets very slow (3 times slower?) when the window is showing on both screens.

Cheers,
Mikael

Windows MediaPlayer 6.4 (not tried with more recent versions) has exactly that issue when its display is split across 2 displays.

However, this was using 2 seperate graphics cards - a Geforce2gts, and a very old trident PCI card.

I’d wager its a driver/windows/directX limitation.

Yeah, dual monitor support in Windows I’ve found to be very quirky whether its Java, my software DVD player, or playing Doom3 without first disabling the second monitor.

For what it’s worth though, it’s not too difficult to get things moving again when dragging your JFrame from one monitor to another. In my code I have:


public class GameParentFrame extends JFrame implements ComponentListener
{
      private ArrayList deviceSpace = new ArrayList();
      public void initView()
      {
            addComponentListener(this);
            initGraphicsEnvironment();
        }
      public void initGraphicsEnvironment()
      {
            GraphicsDevice[] deviceList = GraphicsEnvironment.getLocalGraphicsEnvironment().getScreenDevices();
            for (int x=0;x<deviceList.length;x++)
            {
                  GraphicsDevice gd = deviceList[x];
                  GraphicsConfiguration gc = gd.getDefaultConfiguration();
                  Rectangle bounds = gc.getBounds();
                  if (bounds != null)
                  {
                        deviceSpace.add(bounds);
                  }
            }
      }
      
      public Rectangle getDeviceLocation(GraphicsConfiguration gConfig)
      {
            System.out.println("Device origin= " + gConfig.getBounds().getX() + ", " + gConfig.getBounds().getY()); //$NON-NLS-1$ //$NON-NLS-2$
            return gConfig.getBounds();
      }
      public void componentMoved(ComponentEvent e)
      {
            //check for spatial location and reset the tickers if necessary to prevent them from "freezing" on a device context change
            Rectangle currentBounds = getBounds();
            for (int x=0;x<deviceSpace.size();x++)
            {
                  Rectangle deviceBounds = (Rectangle)deviceSpace.get(x);
                  if (deviceBounds.intersects(currentBounds))
                  {
                        if (deviceLocation != x)
                        {
                              deviceLocation = x;
                              view.notifyDeviceContextChanged();
                        }
                  }
            }
      }
}

and then in my view code where I extend Canvas and have a BufferStrategy setup I have:


        public void deviceContextChanged()
      {
            trackComponent.resetDrawing();
      }
        public void resetDrawing()
      {
            recreateBufferStrategy();
      }
      public void recreateBufferStrategy()
      {
            if ((running == true) && (isVisible() == true))
            {
                  if ((getHeight() > 0) && (getWidth() > 0))
                  {
                        createBufferStrategy(3);
                        strategy = getBufferStrategy();
                  }
            }
      }

So as the frame is dragged from window to window, it will recreate the buffer strategy and get the animation rolling again. It flickers a little while it’s in the middle of the two monitors while its being dragged but seems to work OK. Of course it would be better if it recreated the BufferStrategy only after the drag is complete, but I could never figure out how to get Java to notify me when the dragging of a JFrame is finished.

It should work fine, so it could be a problem with the configuration. But then again it could be our bug. I don’t think we’ve tested BufferStrategy on multiscreen much, as we haven’t seen it as a priority.

BTW, the GraphicsConfiguration of a component actually changes when you move it to a different screen (or, to be more presize, when more than a half of a component is moved to another screen).