jogl and JTabbedPane

I have a separate GLCanvas object on each of several tabs of a JTabbedPane. Everything works as expected until I open a dialog --any dialog-- after which the graphics mysteriously disappear on all tabs except the one that was current when the dialog was opened! The only way I have been able to recover the “lost” graphics is to remove tabs until only one remains whereupon (drum roll please!) the missing graphic magically reappears. To make matters even more confusing, the unexpected behavior just described occurs on my desktop machine but not on my laptop. Both are running Windows XP, and I am using JSDK 1.4.2_04 and jogl 1.0 (April 12 release) on both. The display adapter on the laptop is an NVIDIA GeForce4 440 Go; that on the desktop is an NVIDIA GeForce4 Ti 4600.

Any ideas about what’s going on here? I am completely mystified.

Are you specifying -Dsun.java2d.noddraw=true on the Java command line? If not, please try that.

Ken,
Tried your suggestion, but it made no difference.

Could you please bundle your app into a test case and submit a bug on the JOGL Issues page on java.net? Thanks.

Its been more than a year since my initial post, and I have recently updated to Jogl 1.1 and JRE 1.5, but the problem I described initially persists. I have finally taken the time to boil my rather complex code down to the essentials. I invite anyone to compile and execute the code given below. A GLCanvas is placed on each of two tabs in a JTabbedPane. On closing the application, a dialog appears; select “No” to resume, then switch tabs. The graphic on the tab not visible when the dialog was opened is now gone, with seemingly no way to recover. As stated in my original post, this behavior occurs on my desktop machine but not my laptop. Any ideas are welcome.

import java.awt.;
import java.awt.event.
;
import javax.swing.;
import javax.swing.event.
;

import net.java.games.jogl.*;

public class JoglTest extends JFrame {

public static void main (String [] args) {	  
	EventQueue.invokeLater (new Runnable () {
		public void run () {
			new JoglTest ();
		}
	});
}

private JoglTest () {
	setTitle ("JoglTest");
	setSize (640, 480);
	setDefaultCloseOperation (WindowConstants.DO_NOTHING_ON_CLOSE);

	addWindowListener (new WindowAdapter () {
		public void windowClosing (WindowEvent event) {
			String query = "Do you wish to exit?";
			int opt = JOptionPane.showConfirmDialog (JoglTest.this, query, "", JOptionPane.YES_NO_OPTION);

			if (opt != JOptionPane.YES_OPTION) return;
			System.exit (1);
		}
	});

	JTabbedPane tp = new JTabbedPane ();
	tp.addTab ("black", new JoglTab (Color.black));
	tp.addTab ("red", new JoglTab (Color.red));		
	add (tp, BorderLayout.CENTER);

	setVisible (true);
}

//Inner Class
class JoglTab	extends JPanel implements GLEventListener {

	Color axisColor;

	public JoglTab (Color axisColor) {
		this.axisColor = axisColor;

		GLCapabilities caps = new GLCapabilities ();
		GLCanvas canvas = GLDrawableFactory.getFactory ().createGLCanvas (caps);
		canvas.addGLEventListener (this);

		setLayout (new BorderLayout ());
		add (canvas, BorderLayout.CENTER);
	}

	//GLEventListener Interface
	public void display (GLDrawable drawable) {
		GL gl = drawable.getGL();
		float [] bg = Color.white.getColorComponents (null);
		gl.glClearColor (bg [0], bg [1], bg [2], 0.0f);
		gl.glClear (GL.GL_COLOR_BUFFER_BIT);
	
		gl.glMatrixMode (GL.GL_MODELVIEW);
		gl.glLoadIdentity ();
		
		//Draw Axes
		gl.glColor3fv (axisColor.getColorComponents (null));
		
		gl.glBegin (GL.GL_LINES);
		gl.glVertex2d (-1d, 0d);
		gl.glVertex2d (+1d, 0d);
		gl.glVertex2d (0d, -1d);
		gl.glVertex2d (0d, +1d);
		gl.glEnd ();
	}

	public void displayChanged (GLDrawable drawable, boolean modeChanged, boolean deviceChanged) {}

	public void init (GLDrawable drawable) {}

	public void reshape (GLDrawable drawable, int x, int y, int width, int height) {
		GL gl = drawable.getGL ();
		GLU glu = drawable.getGLU ();
		gl.glViewport (0, 0, width, height); //set the current viewport
		
		
		gl.glMatrixMode (GL.GL_PROJECTION);
		gl.glLoadIdentity ();
		glu.gluOrtho2D (-1d, +1d, -1d, +1d);
	}
}

}

I’ve tried your test on ATI and NVidia hardware on Windows XP and on NVidia hardware on Solaris/x86 with NVidia’s drivers and it works fine in all cases. My only suggestion at this point would be to upgrade the drivers on your desktop.

Thanks, Ken, for your prompt reply. I will try your suggestion.