Posted by
dave_xenos on
May 19, 2015; 2:19am
URL: https://forum.jogamp.org/JOGL-netbeans-gui-builder-how-to-properly-show-a-GLcanvas-tp4034496.html
I usually use netbeans GUI builder to layout a JFrame. There is a very old netbeans plugin (
http://plugins.netbeans.org/plugin/3260/netbeans-opengl-pack) which adds GLCanvas component to be drag-dropped onto a frame.
But that plugin uses a very old jogl version. There is no plugin for the newer ones.
When using the newer versions of jogl, what is the properway to design using netbeans GUI builder?
I tried to do this by using 'custom-component' feature of netbeans. This is done (my way) by wrapping the com.jogamp.opengl.awt.GLCanvas class in another (empty) class, like this:
public class GLCanvasWrapper extends GLCanvas{
}
Then in the GUI designer I use 'Beans' and provide the wrapper class' full path. This allows me to drag-drop the GLCanvas component on to the JFrame like any other component. But when I run the program, it gives me a blank GLCanvas (it shows what's behind it, not just black).
After some time I found the problem is the code generated by netbeans when you create a JFrame.
When you create a JFrame form in netbeans it automatically adds :
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new GLFrame().setVisible(true);
}
});
at the 'main' method. I have to remove that invokeLater to make GLCanvas to display normally (just "new GLFrame().setVisible(true);" at main).
Now, removing that generated code makes me feel I did something the wrong way. And indeed sometimes the frame would be displayed with 0 (zero) height!
So, how do i properly show a GLcanvas with this setup?