1 Reply Latest reply on Sep 7, 2012 10:24 AM by walterln

    Crash of swing components with JOGL and 2 screens on Linux


      We discovered a swing crash on Linux and with two screens.

      To reproduce, implement a JFrame composed by a simple JButton and a JPanel. In the panel, add a JOGL context to draw a simple image (for example).
      (or download this java project : https://rapidshare.com/#!download|421p10|996739028|BugSwingJOGL.tar.gz|3772|0|0 )

      The problem is : when you move the frame from the first screen to the second, and when the screen separation cuts the JFrame in two parts with the same width (call it the "bug position"), most of the time, swing components visually crash. Nevertheless, it seems they still work : for example, it's possible to click on a button and it works (it just looks like a gray rectangle all the time after the crash).

      This problem appeared with Java 7, several weeks ago.

      Other information, this bug appears on Linux (tested on Red Hat and Fedora), not on Windows (it works correctly on it). And the JOGL version is not important (We have the 1.1.1a version, but we tested with the last JOGL version and the problem is the same).

      When the frame is in the "bug position", it seems that Java7 calls, at the screen change, the method Component.setGraphicsConfiguration which do a "removeNotify" followed by a "addNotify".
      The real problem is when a component is composed by a OpenGL context : "removeNotify" and "addNotify" respectively destroy and create the OpenGL context, then the frame blinks, teleports itself on the other screen, and swing components crash. More, destroying and creating the OpenGL context at each screen change is heavy with big scenes and performance drop...
      On Windows, the method Component.setGraphicsConfiguration is called too, but it considers that an update of GraphicsConfig is not necessary, and doesn't call "removeNotify" and "addNotify".