Ahoy!
In this small program there is a JDesktopPane with 3 JInternalFrame-s. In two of the JInternalFrames-s are GLJPanel-s. If I resize these iframes fast a lot of times, init is called randomly /at least randomly for me/. I taught init is called only once per instance. Is this normal behavior or a bug?
package jogl01;
public class Main
{
public static class MyDesktopPane extends javax.swing.JDesktopPane
{
protected MyGLInternalFrame _glFrame;
protected MyGLInternalFrame _glFrame2;
public MyDesktopPane ()
{
super ();
this._glFrame = new MyGLInternalFrame ();
this._glFrame.setBounds (50, 20, 200, 300);
this._glFrame.setVisible (true);
this.add (this._glFrame);
((javax.swing.plaf.basic.BasicInternalFrameUI) this._glFrame.getUI ())
.setNorthPane (null);
this._glFrame2 = new MyGLInternalFrame ();
this._glFrame2.setBounds (300, 10, 200, 300);
this._glFrame2.setVisible (true);
this.add (this._glFrame2);
javax.swing.JInternalFrame other = new javax.swing.JInternalFrame ("", true);
other.setBackground (new java.awt.Color (1.0f, 1.0f, 0.0f, 0.3f));
other.setOpaque (false);
other.setBounds (200, 200, 200, 200);
other.setVisible (true);
this.add (other);
this.moveToFront (other);
}
}
public static class MyGLInternalFrame extends javax.swing.JInternalFrame
{
protected net.java.games.jogl.GLJPanel _glPanel;
public MyGLInternalFrame ()
{
super ("Place of the Title", true);
net.java.games.jogl.GLCapabilities cap =
new net.java.games.jogl.GLCapabilities ();
cap.setHardwareAccelerated (true);
cap.setDoubleBuffered (true);
this._glPanel = net.java.games.jogl.GLDrawableFactory.getFactory ()
.createGLJPanel (cap);
this._glPanel.addGLEventListener (new net.java.games.jogl.GLEventListener ()
{
public void display (net.java.games.jogl.GLDrawable aD)
{
net.java.games.jogl.GL gl = aD.getGL ();
net.java.games.jogl.GLU glu = aD.getGLU ();
gl.glClear (net.java.games.jogl.GL.GL_COLOR_BUFFER_BIT);
gl.glBegin (net.java.games.jogl.GL.GL_TRIANGLES);
gl.glColor4d (1.0, 0.0, 0.0, 0.0);
gl.glVertex3f ( 0.0f, 0.0f, 0.0f);
gl.glColor4d (0.0, 1.0, 0.0, 0.5);
gl.glVertex3f (300.0f, 100.0f, 0.0f);
gl.glColor4d (0.0, 0.0, 1.0, 1.0);
gl.glVertex3f ( 100.0f, 300.0f, 0.0f);
gl.glEnd ();
}
public void displayChanged (net.java.games.jogl.GLDrawable aD,
boolean aModeChanged, boolean aDeviceChanged) {}
public void init (net.java.games.jogl.GLDrawable aD)
{
net.java.games.jogl.GL gl = aD.getGL ();
net.java.games.jogl.GLU glu = aD.getGLU ();
java.util.Random rnd = new java.util.Random ();
gl.glBlendFunc (net.java.games.jogl.GL.GL_SRC_ALPHA,
net.java.games.jogl.GL.GL_ONE_MINUS_SRC_ALPHA);
gl.glClearColor
(rnd.nextFloat (), rnd.nextFloat (), rnd.nextFloat (), rnd.nextFloat ());
gl.glDisable (net.java.games.jogl.GL.GL_DEPTH_TEST);
gl.glEnable (net.java.games.jogl.GL.GL_BLEND);
gl.glMatrixMode (net.java.games.jogl.GL.GL_PROJECTION);
gl.glLoadIdentity ();
glu.gluOrtho2D (0.0f, 800.0f, 600.0f, 0.0f);
gl.glMatrixMode (net.java.games.jogl.GL.GL_MODELVIEW);
gl.glLoadIdentity ();
System.out.println ("Howdie! Init speaking.");
}
public void reshape (net.java.games.jogl.GLDrawable aD,
int x, int y, int width, int height)
{
aD.getGL ().glViewport (0, 0, width, height);
}
});
this.add (this._glPanel);
}
}
public static void main (String [] aArgs)
{
javax.swing.JFrame f = new javax.swing.JFrame ("Jogl01");
f.add (new MyDesktopPane ());
f.setSize (800, 600);
f.setDefaultCloseOperation (javax.swing.JFrame.EXIT_ON_CLOSE);
f.setVisible (true);
}
}
Tested with:
jogl 11b10
Sun Java 1.5.0_01
Windows XP SP2
Gef4 TI4200