JOGL flickers under Mustang build 70

I’ve just upgraded to Mustang build 70 from build 66. The latest release gives some bad flickering when mixing swing and GLCanvas. In the below example, you can see tis by pressing and holding the button along the bottom of the window, or by right clicking in the GLCanvas are to bring up a popup menu. For some reason, the popup menu only flickers some of the time.

`/*

  • TestFrame.java
  • Created on February 1, 2006, 11:35 AM
    */

package com.pantometrics.display;

import java.awt.BorderLayout;
import java.awt.Component;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import net.java.games.jogl.Animator;
import net.java.games.jogl.GLCapabilities;
import net.java.games.jogl.GLDrawable;
import net.java.games.jogl.GLDrawableFactory;

/**
*

  • @author kitfox
    */
    public class TestJOGLFrame extends javax.swing.JFrame
    {
    private GLDrawable canvas;
    Animator animator;

    /** Creates new form TestFrame */
    public TestJOGLFrame()
    {
    canvas = GLDrawableFactory.getFactory().createGLJPanel(new GLCapabilities());

     add((Component)canvas, BorderLayout.CENTER);
     
     animator = new Animator((GLDrawable)canvas);
     animator.start();
    
     
     getContentPane().add((Component)canvas, BorderLayout.CENTER);
     
     setSize(640, 480);
    

    }

    /** This method is called from within the constructor to

    • initialize the form.

    • WARNING: Do NOT modify this code. The content of this method is

    • always regenerated by the Form Editor.
      */
      //
      private void initComponents()
      {
      popup_main = new javax.swing.JPopupMenu();
      jMenuItem1 = new javax.swing.JMenuItem();
      jMenuItem2 = new javax.swing.JMenuItem();
      jButton1 = new javax.swing.JButton();

      popup_main.setLightWeightPopupEnabled(false);
      jMenuItem1.setText(“Item”);
      popup_main.add(jMenuItem1);

      jMenuItem2.setText(“Item”);
      popup_main.add(jMenuItem2);

      setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
      jButton1.setText(“jButton1”);
      getContentPane().add(jButton1, java.awt.BorderLayout.SOUTH);

      pack();
      }//

    /**

    • @param args the command line arguments
      */
      public static void main(String args[])
      {
      java.awt.EventQueue.invokeLater(new Runnable()
      {
      public void run()
      {
      new TestFrame().setVisible(true);
      }
      });
      }

    class Popup implements MouseListener
    {
    public void mouseClicked(MouseEvent e)
    {
    }

     public void mousePressed(MouseEvent e)
     {
         if (e.isPopupTrigger())
         {
             popup_main.show(e.getComponent(), e.getX(), e.getY());
         }
     }
    
     public void mouseReleased(MouseEvent e)
     {
         if (e.isPopupTrigger())
         {
             popup_main.show(e.getComponent(), e.getX(), e.getY());
         }
     }
    
     public void mouseEntered(MouseEvent e)
     {
     }
    
     public void mouseExited(MouseEvent e)
     {
     }
    

    }

    // Variables declaration - do not modify
    private javax.swing.JButton jButton1;
    private javax.swing.JMenuItem jMenuItem1;
    private javax.swing.JMenuItem jMenuItem2;
    private javax.swing.JPopupMenu popup_main;
    // End of variables declaration

}

`

Sorry but I can’t reproduce this behavior. First, either the test case above is incorrect or it got messed up during posting, because several things like the adding of the button and the Popup MouseListener were missing. Second, with both Mustang build 66 and build 70, and with both the old JOGL 1.1.1 and the current JSR-231 build, the test case once fixed works fine on my machine.

What OS, graphics card, and driver level are you running? Are you running the latest set of drivers from your vendor? This is standard information we always need when investigating any problem.

I fixed the test case to behave as I thought you intended. One thing I noticed during this cleanup is that the GLJPanel was being added twice to the JFrame. This looks like a bug to me. Please try the attached test case(s) (the first one works with the current JOGL, while the second one works with JOGL 1.1.1) and see if the behavior is still there.

Looks like the code I posted had it’s main() method creating an instance of the wrong object, which was the cause of the bugs and my mistaken observations. Swing does indeed seem to render correctly with JOGL even under build 70, so I’ll need to look for my errors in something that I’m doing. Thanks for your help.

the are always problems in mixing swing and jogl especialy with popup menus so you should use function setDefaultLightweightPopupEnabled(), i was using it in java 1.5.0
and do not tested in mustang but you can try. Generally it force swing to use AWT Components to render menus, so flickering should not occur.
In your code make:

popup_main.setDefaultLightWeightPopupEnabled(false);

more about mixing heavy and lightweight components you will find here: http://java.sun.com/products/jfc/tsc/articles/mixing/index.html