import net.java.games.jogl.*; import javax.swing.*; import java.awt.*; public class TestProgram { private static class Renderer implements GLEventListener { public void display( GLDrawable drawable ) { GL gl = drawable.getGL(); gl.glClear(GL.GL_COLOR_BUFFER_BIT); gl.glMatrixMode(GL.GL_MODELVIEW); gl.glLoadIdentity(); gl.glBegin( GL.GL_TRIANGLES ); gl.glVertex2d(-1.0, -1.0 ); gl.glVertex2d(1.0, -1.0); gl.glVertex2d(0.0, 1.0); gl.glEnd(); gl.glFlush(); } public void displayChanged(GLDrawable drawable, boolean modeChanged, boolean deviceChanged) { } public void init(GLDrawable drawable) {} public void reshape( GLDrawable drawable, int x, int y, int w, int h){ GL gl = drawable.getGL(); gl.glMatrixMode(GL.GL_PROJECTION); gl.glLoadIdentity(); gl.glOrtho(-2.0, 2.0, -2.0, 2.0, -1, 1 ); } } public static void main( String[] args ) { JFrame frame = new JFrame(); JPanel mainPanel = new JPanel(); mainPanel.setLayout( new BorderLayout() ); Renderer rend = new Renderer(); GLCanvas can = GLDrawableFactory.getFactory().createGLCanvas(new GLCapabilities()); can.addGLEventListener( rend ); mainPanel.add(can, BorderLayout.CENTER ); JPanel buttonPanel = new JPanel(); buttonPanel.add( new JButton("Button One") ); buttonPanel.add( new JButton("Button Two") ); mainPanel.add(buttonPanel, BorderLayout.SOUTH); frame.getContentPane().add(mainPanel); frame.setSize( 400,400); frame.show(); } }