Is it possible to use JOGL GLCanvas on Jtable cells?

49 Views Asked by At

I'm trying to create a JTable containing JOGL GLCanvas or GLJPanel on table's cells.

I define a custom table cell renderer that inherits from the GLJPanel and call the addGLEventListener to define my custom draw on the display method (for the moment I'm trying to draw the same on each cell). I define the getTableCellRendererComponent that returns the custom table itself.

Here is my code of the cell renderer :

private static class GLCellRenderer extends GLJPanel implements TableCellRenderer {
    private String value;
    private Color color;

    public GLCellRenderer () {
        super(new GLCapabilities(GLProfile.getDefault()));

        addGLEventListener( new GLEventListener() {

            @Override
            public void init( GLAutoDrawable glautodrawable ) {}

            @Override
            public void dispose( GLAutoDrawable glautodrawable ) {}

            @Override
            public void display( GLAutoDrawable glautodrawable ) {
                GL2 gl = glautodrawable.getGL().getGL2();
                gl.glClearColor(1, 0, 0, 1);
                gl.glClear(GL.GL_COLOR_BUFFER_BIT);
            }
        });            
    }

    @Override
    public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, boolean hasFocus, int row,int column) {          
        return this;
    }
}

And here is my code to apply the cell renderer to the table :

JTable table = new JTable(model);
table.setDefaultRenderer(Data.class, new GLCellRenderer());

When launching, I have a table with white cells when I'm expecting red cells.

Is it possible to use GLCanvas or GLJpanel on table cell?

0

There are 0 best solutions below