title: Getting NullpointerException on JFrame setvisible(true)
body: <p>I got the following exception when i tried to do frame.setvisible(true);</p>
  
  <pre><code>java.lang.reflect.InvocationTargetException at
  sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at
  sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) at
  sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at
  java.lang.reflect.Method.invoke(Unknown Source) at
  com.myapp.GeneralEventProc.cmdProc(GeneralEventProc.java:43)
  at tcl.lang.Parser.evalObjv(Parser.java:810) at
  tcl.lang.Parser.eval2(Parser.java:1209) at
  tcl.lang.Interp.eval(Interp.java:2042) at
  tcl.lang.Interp.eval(Interp.java:2071) at
  javaapps.JScriptProcessor.processCurrentScript(JScriptProcessor.java:389)
  at
  javaapps.JScriptProcessor.processQueuedScripts(JScriptProcessor.java:632)
  at javaapps.JSPThread.run(JSPThread.java:43) Caused by:
  java.lang.NullPointerException at
  java.awt.FlowLayout.layoutContainer(Unknown Source) at
  java.awt.Container.layout(Unknown Source) at
  java.awt.Container.doLayout(Unknown Source) at
  java.awt.Container.validateTree(Unknown Source) at
  java.awt.Container.validateTree(Unknown Source) at
  java.awt.Container.validateTree(Unknown Source) at
  java.awt.Container.validateTree(Unknown Source) at
  java.awt.Container.validateTree(Unknown Source) at
  java.awt.Container.validateTree(Unknown Source) at
  java.awt.Container.validateTree(Unknown Source) at
  java.awt.Container.validate(Unknown Source) at
  java.awt.Window.show(Unknown Source) at
  java.awt.Component.show(Unknown Source) at
  java.awt.Component.setVisible(Unknown Source) at
  java.awt.Window.setVisible(Unknown Source) at
  com.myapp.mylist.makeList(Unknown Source) at
  com.myapp.mylist.show(MyList.java:144) 
  </code></pre>
  
  <p>The source code is :</p>
  
  <pre><code>public void makeList() {
  
      synchronized (initLock) {
  
          System.out.println(" locking... makeList");
  
          if (_myFrame != null) {
              initiateList();
              _myFrame .setVisible(true);
          } else {
              System.out.println("myframe is null");
          }
  
      }
  
  }
  
  private void initiateList() {
  
      _myFrame.getContentPane().setLayout(null);
      _myFrame.getContentPane().removeAll();
      _myapp.setBounds(0, 0, getWidth(), (int) (getHeight() * 0.90));
      _myFrame.getContentPane().add(_myapp);
      _myFrame.getContentPane().add(_myPanel);
      _myPanel.setBounds(0, (int) (getHeight() * 0.90), getWidth(), (int) (getHeight() * 0.10));
      _myFrame.validate();
      _myFrame.repaint();
  
  }
  </code></pre>
  
  <p>In the above code two methods <code>makeList()</code>, <code>initiateList()</code>.</p>
  
  <p>From <code>makeList()</code> method we are calling <code>initiateList()</code> method after checking the <code>_myFrame</code> is not null within synchronized. Then after returning from the method when i do <code>_myFrame.setVisible(true);</code> the NPE occurs. </p>
  
  <p>Note: This issue happened once and its not reproducible.</p>
  
  <p>Is there any bug in java layer?</p>
  
  <p>Please help me out of this.</p>
  
  <p>Thanks in advance.</p>