How to update a display between an awt screen and a jogl canvas?

I’m newbie on jogl. My current work is about to get user input through a TextField ( on a window of java awt), then use it to select database. Based on what I get from database, modify a chart and display it on the screen. The part of modify the chart is done on a canvas, which is defined as the following. The canvas is added to a awt frame. The Render object is GLEventListener. The Render class implements 4 methods: display(), displayChanged(), init(), reshape(). The code is based on Chris Adamson’s JOGL2DBasics.java of Jumping into JOGL at http://today.java.net/pub/a/today/2003/09/11/jogl2d.html.


GLCapabilities capabilities = new GLCapabilities();
canvas = GLDrawableFactory.getFactory().createGLCanvas(capabilities);

    glEventListener = new Renderer();
    canvas.addGLEventListener(glEventListener);


the Render object is GLEventListener. The Render class implements 4 methods: display(), displayChanged(), init(), reshape().

     public void display (GLDrawable drawable) {
             System.out.println ("display()");
             GL gl = drawable.getGL();
             GLU glu = drawable.getGLU();
             gl.glClear (GL.GL_COLOR_BUFFER_BIT);
             drawSomeLines(gl);
             initChart();
             Color color = null; 

             if(!dataSet.isEmpty()){                              // where dataSet is got from querying the database. 
    		.....
                   [b]updateChart();[/b]
                    .....
    	 }
    	 gl.glFlush();
    }
    
    /** Called by drawable to indicate mode or device has changed*/
 
    public void displayChanged (GLDrawable drawable, boolean modeChanged, boolean deviceChanged) {
               System.out.println ("displayChanged()");
    }

    /** Called after OpenGL is init'ed */

    public void init (GLDrawable drawable) {
              System.out.println ("init()");
    
               GL gl = drawable.getGL(); 
               // set erase color
               gl.glClearColor( 1.0f, 1.0f, 1.0f, 1.0f ); //white 
               // set drawing color and point size
               gl.glColor3f( 0.0f, 0.0f, 0.0f ); 
               gl.glPointSize(4.0f); //a 'dot' is 4 by 4 pixels 
    }

     /** Called to indicate the drawing surface has been moved and/or resized*/
  
     public void reshape (GLDrawable drawable, int x, int y, int width, int height) {
           System.out.println ("reshape()");
           GL gl = drawable.getGL(); 
           GLU glu = drawable.getGLU(); 
           gl.glViewport( 0, 0, width, height ); 
           gl.glMatrixMode( GL.GL_PROJECTION );  
           gl.glLoadIdentity(); 
           glu.gluOrtho2D( 0.0, 450.0, 0.0, 375.0); 
    }

What I’m done doesn’t work. I check the dataSet return from the database is correct. But I’m not sure how the chart on canvas can be updated. It seems to me that this glEventListener should detect something need to be changed. In other words, which method I should work on to update the chart? If anyone can point me a direction, or reference, or any sugestion, I’ll really appreciate it.

Thanks

johio

Try invoking repaint() or display() on the GLCanvas when the data set changes. See the section on “Multithreading Issues” in the JOGL User’s Guide.