Toolbar Configurations

If you define XML files that conform to the, 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:


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

Posted by Oliver on November 18, 2009 at 06:02 PM PST #

The FAQ entry is gone. I think replaces it

Posted by Jirka on February 03, 2010 at 04:50 PM PST #

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 ?

Posted by Sam on December 02, 2010 at 10:52 PM PST #

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

Posted by Geertjan Wielenga on December 02, 2010 at 10:55 PM PST #

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?

Posted by Nigel Thomas on November 22, 2012 at 02:30 AM PST #

Yes, of course.

Posted by Geertjan on November 22, 2012 at 02:43 AM PST #

Post a Comment:
  • HTML Syntax: NOT allowed

Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.


« August 2016