GLCanvas and JtabbedPane problem

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

GLCanvas and JtabbedPane problem

fzanelli
I have experienced a problem that didn't appear in version 2 rc 11 but appears since version 2.1.0.
I have a Jframe with a JtabbedPane composed by 2 Tabs and a GLCanvas always contained in the panel of the selected tab. When I switch form tab1 to tab2, glcanvas is added to tab2, when I switch back to tab1 glcanvas is added to tab1.
The problem is when I switch back to tab1, glcanvas disappear. I post the code of my simple application:

public class JoglTabbedPaneError extends JFrame {

    private GLCanvas glCanvas;
    private JPanel panel1;
    private JPanel panel2;
    private final JTabbedPane tabbedPane;

    public JoglTabbedPaneError() {
        panel1 = new javax.swing.JPanel();
        panel2 = new javax.swing.JPanel();

        panel1.setLayout(new BorderLayout());
        panel2.setLayout(new BorderLayout());

        GLProfile profile = GLProfile.get(GLProfile.GL2);
        GLCapabilities glCapabilities = new GLCapabilities(profile);        
        glCanvas = new GLCanvas(glCapabilities);
        panel1.add(glCanvas, BorderLayout.CENTER);

        tabbedPane = new JTabbedPane();
        tabbedPane.addTab("tab1", panel1);
        tabbedPane.addTab("tab2", panel2);

        tabbedPane.addChangeListener(new javax.swing.event.ChangeListener() {
            @Override
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                if (glCanvas == null) {
                    return;
                }
                if (tabbedPane.getSelectedIndex() == 0) {
                    panel1.add(glCanvas, BorderLayout.CENTER);
                } else {
                    panel2.add(glCanvas, BorderLayout.CENTER);
                }
            }
        });

        setContentPane(tabbedPane);        
        setSize(640,480);
        setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        new JoglTabbedPaneError().setVisible(true);
    }

}

If I use jogl 2.0.0 or jogl 2 rc11 I can switch from tab1 to tab2 and viceversa and this problem doesn't appear
Can you help me to understand what is wrong?
Thank you

Reply | Threaded
Open this post in threaded view
|

Re: GLCanvas and JtabbedPane problem

gouessej
Administrator
Hi

It seems that a regression appeared between JOGL 2.0 and JOGL 2.1. Please fill a bug report, put as much information as you can, including your short example, your OS, VM, version number of driver, ...
Julien Gouesse | Personal blog | Website