Geertjan's Blog

  • January 16, 2007

Toolbar Configurations

Geertjan Wielenga
Product Manager
If you define XML files that conform to the http://www.netbeans.org/dtds/toolbar.dtd, you can set up toolbar configurations and dynamically show or hide your toolbars. Everything I know about this I read in the FAQ: How do I hide and show toolbars the way the debugger does?. Handily, the IDE comes with two of its own toolbar configuration files, called Coding.xml and Debugging.xml, as you'll find when you expand the Toolbars folders within "<this layer in context>". For example, this is what Coding.xml looks like:

<!DOCTYPE Configuration PUBLIC "-//NetBeans IDE//DTD toolbar//EN" 
<Toolbar name="File" />
<Toolbar name="Edit" />
<Toolbar name="Build" />
<Toolbar name="Debug" visible="false" />
<Toolbar name="Memory" visible="false" />
<Toolbar name="Versioning" visible="false" />

Notice that the Debug toolbar and the Memory toolbar are both set to not be visible. In Debugging.xml, both of these are visible.

So all you need to do, after registering the XML files in the module layer file as described in the FAQ referenced above (which you do not need to do for Coding.xml and Debugging.xml, because these are part of the distribution), is say: "Now I want to use Coding.xml" (or Debugging.xml, depending which one you want). And you do that by simply coding this line:


You'd use that line of code whenever you want a certain toolbar configuration to be displayed, such as when you open a window component group, for example. Here's a very simple example -- a new toolbar where I can click a radiobutton to show or hide a configuration:

Join the discussion

Comments ( 6 )
  • Oliver Thursday, November 19, 2009


    unfortunately the link to FAQ "How to hide and show ..." is gone.

    best regards


  • Jirka Thursday, February 4, 2010

    The FAQ entry is gone. I think http://wiki.netbeans.org/DevFaqHideShowToolbar replaces it

  • Sam Friday, December 3, 2010

    Dear Geertjan,

    I tried to make some of my toolbars to be dynamic based on the topComponent's existence or absence. I created my own customToolbarConfig.xml and change the default Standard.xml to change the visibility of some of my custom-made toolbars to be false so i can let em visible after the required components being active or inactive. My standard.xml file is defined as follows (as if i have a custom created toolbar named MyToolbar) :

    <?xml version="1.0"?>

    <!DOCTYPE Configuration PUBLIC "-//NetBeans IDE//DTD toolbar//EN"




    <Toolbar name="File"/>

    <Toolbar name="Edit"/>

    <Toolbar name="Clipboard" visible="false"/>

    <Toolbar name="Undo/Redo" visible="false"/>

    <Toolbar name="Memory" visible="true"/>

    <Toolbar name="MyToolbar" visible="false"/>



    The problem : First time it works some how ok ( sometimes ). By using ToolbarPool.getDefault().setConfiguration("Standard");


    in the componentactivate or componentdeactivate methods of myTopComponent, i can control the visibility or invisibility of my targeted toolbars.

    After quiting the application and re executing it, it seems the platform doesn't following the standard.xml i have created, and reading from some plain or default standard configurations. It only shows FILE , UNDO/REDO and MYTOOLBAR which are not the things i have defined in my standard.xml.

    the result is the same if create a new toolbar which i wanted to be invisible by changing the standard.xml. The platform doesn't pay attention to the XML file and shows the newly created toolbar. Do you have any idea about this problem ?

  • Geertjan Wielenga Friday, December 3, 2010

    Send your questions here instead: dev at platform dot netbeans dot org

  • Nigel Thomas Thursday, November 22, 2012

    Hi Geertjan,

    I am trying to access the save button in the toolbar.

    I need to over ride the operation done by the save button on the toolbar by my custom code.

    Is there any way to do that?

  • Geertjan Thursday, November 22, 2012
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.