how to remove menubar/toolbar of sketcher

04-07-2006 13:39:21

How can I remove the menubar and the toolbar of MarvinSketch?

ChemAxon 7c2d26e5cf

04-07-2006 13:57:36

In applet, use viewonly and menubar parameters:


Code:
msketch_begin("marvin", 430, 300);


msketch_param("viewonly", "true"); // to hide toolbar


msketch_param("menubar", "false"); // to hide menu bar


msketch_end();






If you use Marvin Beans API, you can restrict the Marvin menubar and toolbar by the following way:


Code:
MSketchPane sketchPane = new MSketchPane();


sketchPane.setParams("viewonly=true\n"); // to hide toolbar


sketchPane.setJMenuBar(null); // to remove the Marvin menu bar






Although the Marvin menu bar is restricted in the above example, Marvin popup menus are still enabled. If you would like to remove also them, use the MarvinPane.setPopupMenusEnabled(boolean) method to deny displaying Marvin popup menus.


Code:
sketchPane.setPopupMenusEnabled(false)

04-07-2006 14:21:55

Thanks for the fast answer.


I would like to remove also the scroll bars. How can I do it?

ChemAxon 7c2d26e5cf

04-07-2006 14:50:48

There is no method to do it. A bit hacking is needed to remove scroll bars.


Code:
        JPanel editpanel = null;


        // search editpanel (first JPanel on the content pane)


        Component[] comps = sketchPane.getContentPane().getComponents();


        for(int i = 0; i < comps.length; i++)


        {


            if(comps[i] instanceof JPanel) {


                editpanel = (JPanel)comps[i];


                break;


            }


        }


        // search scrollbars on the editpanel


        if(editpanel != null) {


            comps = editpanel.getComponents();


            for(int j = 0; j < comps.length; j++) {


                if(comps[j] instanceof JScrollBar) {


                    editpanel.remove(comps[j]); // remove scrollbars


                }


            }


        }