Bug 878 - JAWTWindow's HierarchyListener doesn't set component visible (again) on 'addNotify(..)' - GLCanvas in JtabbedPane disappear
Summary: JAWTWindow's HierarchyListener doesn't set component visible (again) on 'addN...
Alias: None
Product: Jogl
Classification: JogAmp
Component: awt (show other bugs)
Version: 2
Hardware: pc_all all
: --- critical
Assignee: Sven Gothel
Depends on:
Blocks: 849
  Show dependency treegraph
Reported: 2013-10-30 08:57 CET by Franco
Modified: 2013-10-31 04:35 CET (History)
0 users

See Also:
Type: ---
SCM Refs:
Workaround: ---


Note You need to log in before you can comment on or make changes to this bug.
Description Franco 2013-10-30 08:57:07 CET
I have experienced a problem that didn't appear in version 2.0.2 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() {
            public void stateChanged(javax.swing.event.ChangeEvent evt) {
                if (glCanvas == null) {
                if (tabbedPane.getSelectedIndex() == 0) {
                    panel1.add(glCanvas, BorderLayout.CENTER);
                } else {
                    panel2.add(glCanvas, BorderLayout.CENTER);


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


If I use jogl 2.0.2 I can switch from tab1 to tab2 and viceversa and this problem doesn't appear
Comment 1 Sven Gothel 2013-10-31 02:08:55 CET
Regression of commit e33e6374e0be0454f7e9732b5f897f84dbc3c4dc (Fix for Bug 729 and Bug 849) !
Comment 2 Sven Gothel 2013-10-31 03:47:18 CET
 JAWTWindow's HierarchyListener doesn't set component visible (again) on 'addNotify(..)' 

It only renders the component invisible after removeNotify() which is performed implicit anyways ..

Case java.awt.event.HierarchyEvent.DISPLAYABILITY_CHANGED
shall perform similar as our java.awt.event.HierarchyEvent.SHOWING_CHANGED impl.
Comment 3 Sven Gothel 2013-10-31 04:35:22 CET
  - Fixed as described in comment 2
  - Tested on Gnu/Linux X11 and OSX incl. re-test Bug 729 and Bug 849 unit tests.