I'm trying to write a simple molecule viewer with JOGL. The first time I load a PDB file that contains the coordinate of the atoms, instantiate the JOGL and add the GLCanvas to the content pane of a JFrame, everything is working right. But when I use an JFileChooser to load another molecule file, nothing changes and when I resize the windows the canvas does not refresh correctly. The path to the file is correct.
I instantiate a new GLCanvas and a new Renderer class, that contains the display() method and implements the GLEventListner, and these problems with refresh occur.
I tried to reuse the GLCanvas I instantiated the first time, but if I pass the molecule, with the coordinates to the Render class, NullPointerException occurs.
Does anybody have any idea about this problem? Do I have to "refresh" the state of the OpenGL to display something different from the moment of its creation, and if so, how do I do this "refresh"?