Bug 889

Summary: GLCanvas disappear when moves between two JFrame
Product: [JogAmp] Jogl Reporter: Franco <fzanelli>
Component: awtAssignee: Sven Gothel <sgothel>
Status: RESOLVED FIXED    
Severity: critical CC: bart.adams, fzanelli
Priority: ---    
Version: 2   
Hardware: pc_all   
OS: windows   
Type: DEFECT SCM Refs:
45ce96db65fa7cbfd3bcb3dd4503bc6251d2e493
Workaround: ---
Bug Depends on: 729, 816, 849, 928, 937    
Bug Blocks: 906    

Description Franco 2013-11-04 15:53:27 CET
I wrote a code to move a GLCanvas from a JFrame to another and move it back to the first. If I do this operation more than one time the GLCanvas disappear.
I Experienced this problem with version 2.1.2 on windows 7 x64 platform. With jogl 2.0.2 the problem doesn't appear. 

This is the application:

import java.awt.BorderLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.media.opengl.GLCapabilities;
import javax.media.opengl.GLProfile;
import javax.media.opengl.awt.GLCanvas;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.WindowConstants;

/**
 *
 * @author Zanelli Franco. <fzanelli@tecnosens.it>
 */
public class JoglFrameError extends JFrame {

    public JoglFrameError() {

        GLProfile profile = GLProfile.get(GLProfile.GL2);
        GLCapabilities glCapabilities = new GLCapabilities(profile);
        final GLCanvas glCanvas = new GLCanvas(glCapabilities);
        final JPanel container = new JPanel(new BorderLayout());
        container.add(glCanvas);

        setLayout(new BorderLayout());
        // create a button that open a new JFrame and move the GLCanvas
        JButton button = new JButton("Move GlCanvas to new Frame");
        button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(java.awt.event.ActionEvent evt) {                
                final JFrame newFrame = new JFrame();

                // Create a button that move back the GLCanvas to the first frame
                JButton closeBt = new JButton("Move Back the GLCanvas");
                closeBt.addActionListener(new ActionListener() {

                    @Override
                    public void actionPerformed(ActionEvent e) {
                        container.add(glCanvas, BorderLayout.CENTER); 
                        glCanvas.setBounds(0,0, container.getSize().width, getSize().height);
                        newFrame.dispose();
                    }
                });

                newFrame.setSize(320, 240);
                newFrame.setLayout(new BorderLayout());
                newFrame.add(closeBt, BorderLayout.NORTH);
                newFrame.add(glCanvas, BorderLayout.CENTER);                
                newFrame.setVisible(true);

            }
        });

        add(button, BorderLayout.NORTH);
        add(container, BorderLayout.CENTER);
        setSize(640, 480);
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        new JoglFrameError().setVisible(true);
    }
}
Comment 1 Franco 2013-11-04 16:18:19 CET
With jogl version 2.1.1, same OS and platform configuration, the problem doesn't appear. It has been introduced in last release.
Comment 2 Bart Adams 2013-11-08 10:03:30 CET
If you call setVisible(true) on the GLCanvas after newFrame.setVisible(true) it should appear again.
Comment 3 Sven Gothel 2013-11-10 19:10:23 CET
Probably a regression to the fix of Bug 878
jogl git commit 887dbdb34d71a3a266b7854bc9a3842aad1032f9
Comment 4 Sven Gothel 2013-11-10 20:38:14 CET
reproduce ..  comment 3 is valid (regression)
Comment 5 Sven Gothel 2013-11-10 21:02:06 CET
45ce96db65fa7cbfd3bcb3dd4503bc6251d2e493
    When JAWTWindow's visibility tracker updates component's local visibility,
    it should read it's local visibility state instead 'trusting' the passed state.
    
    Make JAWTWindow's visibility tracker DEBUG output more brief for readability.


Related: Bug 816, Bug 849, Bug 729

Please re-test all unit tests related to above bugs!

com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos01AWT
com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos02AWT
com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03aB729AWT
com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03bB849AWT
com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos03cB849AWT
com.jogamp.opengl.test.junit.jogl.awt.TestBug816JTabbedPanelVisibilityB849B878AWT
com.jogamp.opengl.test.junit.jogl.awt.TestBug816GLCanvasFrameHoppingB849B889AWT
com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos04aAWT
com.jogamp.opengl.test.junit.jogl.awt.TestBug816OSXCALayerPos04bAWT

May use scripts/tests.sh via scripts/tests-x64.sh .. etc

Please reopen if recuring regression .. above tests worked fine here on GNU/Linux X11.