import java.awt.Frame; import java.awt.event.WindowAdapter; import java.awt.event.WindowEvent; import javax.media.opengl.*; import javax.media.opengl.awt.GLCanvas; import com.jogamp.common.GlueGenVersion; import com.jogamp.common.util.VersionUtil; import com.jogamp.opengl.JoglVersion; public class SimpleScene { public static Frame frame = null; public static void main(String[] args) { System.err.println(VersionUtil.getPlatformInfo()); System.err.println(GlueGenVersion.getInstance()); System.err.println(JoglVersion.getInstance()); GLProfile glp = GLProfile.getDefault(); GLCapabilities caps = new GLCapabilities(glp); final GLCanvas canvas = new GLCanvas(caps); canvas.addGLEventListener( new GLEventListener() { public void init( GLAutoDrawable glautodrawable ) { GL gl = glautodrawable.getGL(); System.err.println("init: "+gl.getContext()); } public void dispose( GLAutoDrawable glautodrawable ) { System.err.println("dispose"); } public void display( GLAutoDrawable glautodrawable ) { } public void reshape( GLAutoDrawable glautodrawable, int x, int y, int width, int height ) { } }); frame = new Frame("AWT Window Test"); frame.setSize(300, 300); frame.add(canvas); frame.setVisible(true); // by default, an AWT Frame doesn't do anything when you click // the close button; this bit of code will terminate the program when // the window is asked to close frame.addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { frame.dispose(); System.exit(0); } }); // wait 3s then end .. try { Thread.sleep(3000); javax.swing.SwingUtilities.invokeAndWait(new Runnable() { public void run() { frame.remove(canvas); frame.dispose(); }}); } catch( Throwable throwable ) { throwable.printStackTrace(); } } }