User 8250a1884c
15-11-2010 17:04:03
Hi,
I am trying to set up a Java application using JChem / MarvinBeans 5.3.7 that reads molecules from an SDF and displays them in a MViewPane.
So far, everything works fine, but I encounter a problem when I want to add customized MouseListeners to the MViewPane as described in the example "CustomMenuExample.java" or the MViewPane API.
mpane = new MViewPane();
mpane.setPopupMenusEnabled(false);
tableSupport = mpane.getTableSupport();
int molcount = 0;
for(Molecule m : mols) {
mpane.setM(molcount, m);
molcount++;
}
for(int i=0; i < mpane.getVisibleCellCount(); i++) {
JComponent comp = mpane.getVisibleCellComponent(i);
comp.addMouseListener(new MviewTableMouseListener());
}
When setting the molecules with the mpane.setM() method as in the code listing above, the mouse events are triggered correctly.
However, if I use the TableSupport.start() method to fill the MViewPane with molecules, there is no response from the mouse listeners:
mpane = new MViewPane();
mpane.setPopupMenusEnabled(false);
tableSupport = mpane.getTableSupport();
tableSupport.start(new ArrayMDocSource(mols), "mols");
for(int i=0;i<mpane.getVisibleCellCount();i++) {
JComponent comp = mpane.getVisibleCellComponent(i);
comp.addMouseListener(new MviewTableMouseListener());
}
How can I trigger mouse events when clicking on a MViewPane table that has been filled with the tableSupport.start() method?
I prefer this way of loading the molecules because I would like to
display the molecules in a spreadsheet-like table (using the table options menu provided by TableSupport.makeTableMenu()) which doesn't seem to
work properly for the first code example. Or would you recommend another way of displaying such a molecule structure/property spreadsheet?
Any hints are much appreciated.
Regards
Lisa