Position of Marvin sketcher/viewer after double-click

User aec227c3cb

18-07-2013 12:21:12

I am using a MViewPane to display my reaction, with the editable property set to SKETCHABLE or VIEW_ONLY depending on the situation.  I'm expecting the user to double-click to open the sketcher or viewer in a seperate window.


Is there a way to position the new window relative to the application?  Currently it's positioned in the upper left corner of my desktop.  


I was experimenting with a MouseListener to listen for a double-click, but I can't seem to intercept the double-click.  I'm thinking of adding a PropertyChangeListener to listen for the windowOpened event and positioning the window at this point.


Is there an easier way to handle this scenario?

ChemAxon 5433b8e56b

22-07-2013 08:19:31

Hi,


unfortunatelly, currently you do not have an option to open the dialog relative to the MViewPane. We can introduce such a behaviour in a future version, but in the mean time I do not see a better opportunity than you are experimenting with.


Perhaps a more simpler way is to listen for the sketchInView property change event, it gives you a reference for the opening MSketchPane, and you can get its window ancestor easily with the help of SwingUtilities. When opening a sketcher, the oldValue of the property change event is null, the newValue contains the reference for the MSketchPane being created, when the sketcher is closing, the oldValue contains the reference, and the newValue is null.


Please note that there can be more sketcher opened at a certain time.


The window ancestor is a JDialog, if you need specific methods for the operations you would like to do on it, you can cast it to JDialog.


I hope this helps.


Regards,
Istvan