hi there,
i am developing a java application that opens a cml or com file and i want
it to show this file in a jmol viewer.
i added all jar files that belongs jmol into a project library, then i added
all source files into source package of that project. then i added that
project into my main project.
now i am trying to add jmolpanel into a JPanel and make it work but i got
""AWT-EventQueue-0" java.lang.NullPointerException" error all the time.
i use this method and call this when user opens a file :
public void JmolView(){
JmolPanel jmolPanel = new JmolPanel();
Jview.add(jmolPanel); // Jview is my JPanel
JmolSimpleViewer viewer = jmolPanel.getViewer();
viewer.evalString("zap");
viewer.openFile(JName);
jmolPanel.setVisible(true);
}
and my jmol class :
static class JmolPanel extends JPanel {
JmolSimpleViewer viewer ;
JmolAdapter adapter;
JmolPanel() {
adapter = new SmarterJmolAdapter();
viewer = JmolSimpleViewer.allocateSimpleViewer(this, adapter);
}
public JmolSimpleViewer getViewer() {
return viewer;
}
final Dimension currentSize = new Dimension();
final Rectangle rectClip = new Rectangle();
public void paint(Graphics g) {
getSize(currentSize);
g.getClipBounds(rectClip);
viewer.renderScreenImage(g, currentSize, rectClip);
}
}
and errors :
run:
Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
at org.jmol.viewer.Viewer.setAppletContext(Viewer.java:333)
at org.jmol.viewer.Viewer.allocateViewer(Viewer.java:280)
at
org.jmol.api.JmolSimpleViewer.allocateSimpleViewer(JmolSimpleViewer.java:49)
at NewJFrame$JmolPanel.<init>(NewJFrame.java:808)
at NewJFrame.JmolView(NewJFrame.java:263)
at NewJFrame.openActionPerformed(NewJFrame.java:698)
at NewJFrame.access$1300(NewJFrame.java:36)
at NewJFrame$17.actionPerformed(NewJFrame.java:537)
at
javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1995)
at
javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2318)
at
javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:387)
at
javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:242)
at javax.swing.AbstractButton.doClick(AbstractButton.java:357)
at
javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI.java:1225)
at
javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(BasicMenuItemUI.java:1266)
at java.awt.Component.processMouseEvent(Component.java:6216)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3265)
at java.awt.Component.processEvent(Component.java:5981)
at java.awt.Container.processEvent(Container.java:2041)
at java.awt.Component.dispatchEventImpl(Component.java:4583)
at java.awt.Container.dispatchEventImpl(Container.java:2099)
at java.awt.Component.dispatchEvent(Component.java:4413)
at
java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4556)
at
java.awt.LightweightDispatcher.processMouseEvent(Container.java:4220)
at java.awt.LightweightDispatcher.dispatchEvent(Container.java:4150)
at java.awt.Container.dispatchEventImpl(Container.java:2085)
at java.awt.Window.dispatchEventImpl(Window.java:2475)
at java.awt.Component.dispatchEvent(Component.java:4413)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:599)
at
java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:269)
at
java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:184)
at
java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:174)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:169)
at
java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:161)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:122)
BUILD SUCCESSFUL (total time: 13 seconds)
it would be great if you help me.
--
Best Regards,
--
Cihan Kamil Öğüt
------------------------------------------------------------------------------
OpenSolaris 2009.06 is a cutting edge operating system for enterprises
looking to deploy the next generation of Solaris that includes the latest
innovations from Sun and the OpenSource community. Download a copy and
enjoy capabilities such as Networking, Storage and Virtualization.
Go to: http://p.sf.net/sfu/opensolaris-get
_______________________________________________
Jmol-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jmol-users