Geertjan's Blog

  • June 19, 2013

Menubars and Toolbars are Optional in the NetBeans Platform

Geertjan Wielenga
Product Manager

The question of the day comes from Ralf Eichinger, a few days ago in the comments in this blog:

Coming from Java EE and starting to refresh my Swing knowledge, I found your very
valuable blog entries.
As I am just starting to have a look at the NetBeans Platform, I am confused at seeing the NetBeans menubar and toolbar in all the example applications. This makes
me think that all applications implemented with the NetBeans Platform must be
heavier than they should be (carrying all the unnecessary menu and toolbar
stuff). I (and probably all old school Swing developers) would like to see
how easy it is to remove an unneccessary menubar or toolbar. And is the end
result (JAR file) smaller when removing these stuff?

And the answer of the day, i.e., in response to the question from Ralf, above, comes from Sean Phillips, who works for NASA on NetBeans Platform applications and will most likely be at JavaOne this year:

What you will find is that the menu and toolbar get populated dynamically by the features you add to your application. It will only be as heavy as you want to make it, though if you want features you have to include the associated support for
GUI components. If it is a matter of just not showing these things, you can hide them quite
easily. Geertjan has written towards that several times, at
for starters.

Great answer, Sean. Indeed, if you don't want a menubar or toolbar in a NetBeans Platform application, simply create a NetBeans module, add a layer file (both of these activities can be done via wizards in NetBeans IDE), and then hide the menubar and toolbar, like this:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE filesystem PUBLIC
"-//NetBeans//DTD Filesystem 1.2//EN"
<folder name="Menu_hidden"/>
<file name="Toolbars_hidden"/>


But this will not make a difference in the size of the application. The code for the menubar and toolbar are still in the application, you've simply prevented them from being displayed. As Sean also points out in his response, you can take a different approach—remove the modules you don't need. If you remove the "org.netbeans.core.ui" module (by right-clicking the application, choosing Properties, expanding "platform", and unselected "Core - UI"), you will not have a toolbar anymore, for example. You can even remove all of the UI components from the NetBeans Platform, if that's what you want to do, as explained in this tutorial, which is the very first tutorial in the "NetBeans Platform Fundamentals" section of the NetBeans Platform Learning Trail:


Also make sure to read the blog entry that Sean points to, which gives you a complete template for starting your own NetBeans Platform application without menubars and toolbars:


Join the discussion

Comments ( 1 )
  • guest Saturday, August 31, 2013

    I need codes for a "back" option in menu bar

Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.