import javax.media.opengl.*; import java.awt.Frame; public class Basic implements GLEventListener { public void display(GLAutoDrawable drawable) { GL gl = drawable.getGL(); gl.glBegin(GL.GL_POLYGON); // draw a square gl.glVertex2f(-0.5f, -0.5f); gl.glVertex2f(-0.5f, 0.5f); gl.glVertex2f(0.5f, 0.5f); gl.glVertex2f(0.5f, -0.5f); gl.glEnd(); } public static void main(String[ ] args) { Frame frame = new Frame("Basic"); // create the frame frame.setSize(500, 500); // give it a size GLCanvas canvas = new GLCanvas(); // create the canvas Basic basic = new Basic(); // create the listener canvas.addGLEventListener(basic); // add listener to canvas frame.add(canvas);//add canvas to window frame.setVisible(true); // show window } public void displayChanged(GLAutoDrawable arg0, boolean arg1, boolean arg2) { // TODO Auto-generated method stub } public void init(GLAutoDrawable arg0) { // TODO Auto-generated method stub } public void reshape(GLAutoDrawable arg0, int arg1, int arg2, int arg3, int arg4) { // TODO Auto-generated method stub } }