JavaFX Menubar control

To continue developing my JavaFX skills I put in a few hours over the last week to build a menubar control. For those unsure on what a menubar is, it is the row at the top of an applications window (on most operating systems) that has the ‘File’, ‘Edit’, ‘Help’, etc menus. The menubar control is therefore responsible for making it easy to add and remove menus and menu items from the menu. For anyone interested in the API for my menubar, you can read the code that must be written to build the menu shown below.

I’m not wanting to go on about it too much now, as it is still in very early development, but you can play with it here. You’ll need to be running a recent Java release to get the best results. Of course, don’t expect much – what you see in the screenshot below is all you get (along with a bit of interactivity). Click the screenshot for a bigger image.



I’m also aware that it is lacking 🙂 Features such as accelerators, mnemonics, grouped menu items, submenu arrows, checks on checked menu items are all coming (some faster than others). As well as this, there are some layout issues that I need to work out – in particular menu width improvements, submenu positioning (overlap), text alignment, etc. Update: Note that the crossed-out tasks have been completed.

For now it’s a tech demo (for me) – hopefully as time permits it may find time to become more polished, and possibly even usable!

16 thoughts on “JavaFX Menubar control”

  1. Good. Should at least display the menu item choice in the application, except for Exit, we don’t have much feedback.
    Might be superseded by some official menu system in next version (hopefully) but yet a good training, as you point out.

    1. The result of clicking on any menuitem is a call to the action function. To debug I have the menuitems printing to the console. A developer using a menu like this of course hooks in proper actions, but for testing purposes the current actions meet my requirements.


      1. Ah, OK, for some reason the Java console status went to “Hidden” while I usually keep it “Always open”, so I missed this feedback. Thanks for pointing it out.

    1. Hehe, well, if I ever make it available feel free to skin it to look like this 🙂 My design preferences are always minimalistic – I like clean borders and straight lines.

      What do you mean by a sidebar effect?


  2. He he. Just pulling your leg.

    Sidebar effect; if you take a peek at the Synthetica link I sent you yesterday, you’ll see that when a menu is unfolded, the left side (where the icons are placed) is visually separated from the menu item texts.

    (I just installed JavaFX in my JFX development environment… I’m getting somewhere on that component)

    1. Ah right, I was actually thinking of adding the ‘sidebar’ effect also – I like how in many windows apps this is done – it makes the GUI nicer looking.

      When I find time I’ll certainly look into adding it.


    1. Thanks for the info – it’s been fixed up. Note that this menu control is relatively dated and better stuff is most probably coming up in JavaFX 1.3.

  3. Hello, I tried your code in NetBeans6.8,
    but JFXtras-0.5.jar from
    seems not to contain :
    What is the solution ?

Comments are closed.