I have problem GLJPanel getContext()

I use GLJPanel and I write below code but I have below error But I do not take any error GLcanvas. I think I take error when I call getContext() method. How can I solve this problem

            Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at javax.media.opengl.GLJPanel.getContext(GLJPanel.java:787)
at FisrtJoglPackage.SceneRenderer.<init>(JOGLDemo5.java:221)
                 ..............
               ..............

public class JOGLDemo5 extends JFrame implements ChangeListener
{
final static int WIDTH = 100;
final static int HEIGHT = 100;

final static int FPS = 30;
private SceneRenderer sr;
FPSAnimator animator;

public JOGLDemo5 ()
{

  super ("JOGLDemo #5");

 
  this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

  GLCapabilities caps=new GLCapabilities();
  caps.setAlphaBits(0);
   sr = new SceneRenderer (caps);
  
  final Animator animator = new Animator(sr);
  sr.setPreferredSize (new Dimension (WIDTH, HEIGHT));

 this.add(sr);
   
 
  initGui();
       
  pack ();
  setVisible (true);
  animator.start();

}

public static void main (String [] args)
{
Runnable r = new Runnable ()
{
public void run ()
{
new JOGLDemo5 ();

                   }
               };
  EventQueue.invokeLater (r);

}

class SceneRenderer extends GLJPanel implements GLEventListener,MouseListener,MouseMotionListener
{
public SceneRenderer ( GLCapabilities caps)
{

  super(caps);
  GLContext context=  this.getContext();
   context.getGL();
   addGLEventListener (this);

}

public void init (GLAutoDrawable drawable)
{

  GL gl = drawable.getGL ();
  glc=drawable.getGL();
  gl.glEnable (GL.GL_DEPTH_TEST);
  gl.glShadeModel(GL.GL_SMOOTH);
  gl.glClearColor(0, 0, 0, 0);

}

public void display (GLAutoDrawable drawable)
{

  GL gl = drawable.getGL ();

    //Draw Something

}

public void reshape (GLAutoDrawable drawable, int x, int y, int width,
int height)
{

}

I guess the problem probably is, that the context is not available as long as the panel is not shown.

Why do you need the context?

I work on the project that I does not make , I must draw swing button on canvas so I change GLCanvas with GLJPanel . as the Result of this I have this error.

So you have to find out why the context is queried from the panel and if you can do without. If you really need the context, maybe you can change the behaviour in a way, that you can call getContext() when the panel is visible.