ChemAxon 7c2d26e5cf
04-06-2004 16:22:36
MViewPane.getM returns null although the molecule are already set.
See the following example:
The problem is that MViewPane.getM is called too early. The molecule has not been loaded yet.
MViewPane.setM(int, String) launches a new thread for loading a molecule and the getM(0) method does not wait until this thread is finished.
Thus, there is no guaranty that the molecule loading process is finished until the method returns. This method is generally used in case of loading a huge set of molecules in the same time. If you use debug option: viewPane.setDebug(2), you can see when the molecule is loaded.
Instead of setM(int, String) use setM(int, File, String) method. Using this method will cause setM to wait until molecule loading is finished.
See the following example:
Code: |
viewPane.setM(0, "mols-2d/caffeine.mol"); Molecule m = viewPane.getM(0); |
The problem is that MViewPane.getM is called too early. The molecule has not been loaded yet.
MViewPane.setM(int, String) launches a new thread for loading a molecule and the getM(0) method does not wait until this thread is finished.
Thus, there is no guaranty that the molecule loading process is finished until the method returns. This method is generally used in case of loading a huge set of molecules in the same time. If you use debug option: viewPane.setDebug(2), you can see when the molecule is loaded.
Instead of setM(int, String) use setM(int, File, String) method. Using this method will cause setM to wait until molecule loading is finished.