Alex, the distinction you need to make is between a Jmol atom "selection" using the SELECT command and a mouse action to pick an atom, which is a callback. You are watching for the select command. What you want to do is implement org.jmol.api.JmolStatusListener. Check out how this is done in The two specific methods you will want to implement are:

    public boolean notifyEnabled(int type)
    public void notifyCallback(int type, Object[] data)

You register your status listener at Jmol viewer allocation time:

    viewer = JmolViewer.allocateViewer(display, modelAdapter,
        null, null, null, appletContext = commandOptions,
        new MyStatusListener());

Where MyStatusListener() implements JmolStatusListener.

Referring to Jmol 11.7 here.


On Thu, Feb 26, 2009 at 7:23 AM, Alexander Klenner <> wrote:
Hi all,

is there a way to add something like the 'SelectionListener' to my
instance of the viewer ( I am using the viewer to visualize some
molecules that are in CDK Molecule representation)
that actually will react if I mouse-klick an atom in the viewer?

I tried the following but that won't do anything so far...

 MyViewer.addSelectionListener(new JmolSelectionListener() {
            public void selectionChanged(BitSet selection) {
                              //do some nice stuff whenever atom is


I do see the system outs from the StatusManager class that confirms,
that I did pick an atom.

Is there a way to do this or do I have to implement something by myself?

Thanks for any help or suggestions,


Alexander Klenner, Dipl.-Bioinf.
Johann Wolfgang Goethe-University Frankfurt
Department of Biosciences
Siesmayerstrasse 70
D-60323 Frankfurt
Tel: +49 (0) 69 798 24879
Fax: +49 (0) 69 798 24880

Open Source Business Conference (OSBC), March 24-25, 2009, San Francisco, CA
-OSBC tackles the biggest issue in open source: Open Sourcing the Enterprise
-Strategies to boost innovation and cut costs with open source participation
-Receive a $600 discount off the registration fee with the source code: SFAD
Jmol-users mailing list

Robert M. Hanson
Professor of Chemistry
St. Olaf College
1520 St. Olaf Ave.
Northfield, MN 55057
phone: 507-786-3107

If nature does not answer first what we want,
it is better to take what answer we get.

-- Josiah Willard Gibbs, Lecture XXX, Monday, February 5, 1900