title: Swing Paint Issues On Secondary Monitor?
body: <p>I recently ran into an issue that I cannot explain.  Hopefully someone knows what I can do to resolve my issue.  I have a dual monitor machine running Windows 7 64-bit. Both monitors are identical models and settings. The primary monitor is on the right. I am using JRE 1.8.0_131</p>
  <p>The issue I am seeing is that recently I discovered I am no longer able to run my Java Swing application on my second monitor.  This was working perfectly fine before, as in I could move my application between both monitors, resizing and switching to/from maximized with no problems.  Now whenever my application is on my second monitor, all I see is a frame that shows the part of my desktop background that is behind the frame</p>
  <p>Below is a small sample program that creates a frame for each monitor.  The frame on my primary monitor looks fine.  The one on my secondary monitor is messed up like I mentioned.  Simply moving the bad frame to my primary monitor does nothing to fix it but if I minimize then restore it looks fine (i.e. if I force the frame to repaint on the primary monitor it looks fine).  Similarly, moving the good frame to the secondary monitor and forcing a repaint results in the bad frame</p>
  <p>My JRE has not been updated in months so that does not seem like the issue.  As an experiment I tried using JDK 1.7.0_17 but it has the same results.  My machine got a Windows update yesterday which maybe coincidentally is when I noticed this issue.  I am not saying that is the issue, just noting the information I have</p>
  <p>Anyhow, any thoughts or suggestions would be greatly appreciated.  This issue is annoying since dual monitor support is helpful for having my application and Eclipse visible at the same time, as well as the fact that my application has multiple frames which I placed one per monitor</p>
  <pre><code>SwingUtilities.invokeLater(new Runnable()
  {
      @Override
      public void run()
      {
          for (final GraphicsDevice device : GraphicsEnvironment
              .getLocalGraphicsEnvironment().getScreenDevices())
          {
              final DisplayMode displayMode = device.getDisplayMode();
  
              LOGGER.debug(
                  &quot;testSwing: device: {}, ID string: {}, isFullScreenSupported: {}, &quot;
                      + &quot;displayModeWidth: {}, displayModeHeight: {}, &quot;
                      + &quot;displayModeBitDepth: {}, displayModeRefreshRate: {}&quot;, device,
                  device.getIDstring(), device.isFullScreenSupported(),
                  displayMode.getWidth(), displayMode.getHeight(), displayMode.getBitDepth(),
                  displayMode.getRefreshRate());
  
              if (GraphicsDevice.TYPE_RASTER_SCREEN == device.getType())
              {
                  final GraphicsConfiguration configuration =
                      device.getDefaultConfiguration();
  
                  final JFrame frame = new JFrame(&quot;Test Frame&quot;, configuration);
                  frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                  frame.getContentPane().add(
                      new JLabel(device.getIDstring(), SwingConstants.CENTER));
  
                  final Rectangle screenBounds = configuration.getBounds();
  
                  frame.setBounds((screenBounds.x + (screenBounds.width / 2)) - 100,
                      (screenBounds.y + (screenBounds.height / 2)) - 100, 200, 200);
  
                  frame.setVisible(true);
              }
          }
      }
  });
  </code></pre>
  <p><strong>NOTE</strong>: LOGGER is just a SLF4J logger which I added only to see if there was any useful information I could gather.  This can be removed when running as it has no effect on the issue described above</p>
  <p>Output from running this on my machine:</p>
  <blockquote>
  <p>testSwing: device: Win32GraphicsDevice[screen=0], ID string: \Display0, isFullScreenSupported: true, displayModeWidth: 1920, displayModeHeight: 1200, displayModeBitDepth: 32, displayModeRefreshRate: 59</p>
  <p>testSwing: device: Win32GraphicsDevice[screen=1], ID string: \Display1, isFullScreenSupported: true, displayModeWidth: 1920, displayModeHeight: 1200, displayModeBitDepth: 32, displayModeRefreshRate: 59</p>
  </blockquote>