I got the following exception when i tried to do frame.setvisible(true);
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)
The source code is :
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();
}
In the above code two methods makeList()
, initiateList()
.
From makeList()
method we are calling initiateList()
method after checking the _myFrame
is not null within synchronized. Then after returning from the method when i do _myFrame.setVisible(true);
the NPE occurs.
Note: This issue happened once and its not reproducible.
Is there any bug in java layer?
Please help me out of this.
Thanks in advance.