Documentation on MenuBarComponent


Hi there

Does anyone happen to have a manual (link) within reach on how to create a menu bar?
This is too little:

Doesn’t need to be a step by step introduction. Some working sample code would do. I just learned that a menu bar is one of the components unavailable in the jucer.

I’d appreciate any hints for this newbie stuff.


Check the demo source code, it has a menu bar.


Demo source code? Closest to “demo” is ‘example projects/juce demo’. Guess, you mean this one. Okay, I opened it in VC++2008. And… as so many stuff in this framework it does not compile. Phew! I mean, what is this? A joke, or what? Okay, guess reading the code must suffice. Thanks.


[quote]And… as so many stuff in this framework it does not compile. Phew! I mean, what is this? A joke, or what?

Yeah, it’s all a joke. For years I’ve been pretending that the demo compiles, just to fool you. So has everyone else, too - they’re all in on the joke.


What are you using to compile? Are you windows, mac or linux? Easiest by far is to just get Visual C++ Express 2008. “It Just Works”. [although you might get some errors compiling if the juce_Config.h settings still default to expecting certain qt/opengl/vst etc… things as it did a while back… but that’s hardly major issues]

Anyway, yes, look at the demo. Also, look further at the documentation; you don’t really do anything with a MenuBarComponent - you do it all via the MenuBarModel. If you can’t find information you need in the docs there, then… well… sorry, but you need to try harder!

But granted, it’s hard to get anywhere if you’re struggling to build even the demo. Try to get at least the helloworld example project built! At least that doesn’t have any fancy stuff like quicktime or opengl or whatnot, and shouldn’t require any tinkering that you’d need some know-what-the-problem-is experience for.


Ok, that was the reason. It’s nice to know that now!
It’s been so many time I struggle to get this to build.


Thanks haydxn for your hints and questions.
I have given up on this and only studied the code and fortunately that was sufficient.
Well, sorry for my outburst. I had one too many dissapointing experience with very basic stuff. That left me somewhat, hm no really, frustrated. I learn new frameworks by the month and never encountered stuff like that. Though in Java.

I can’t hold back to give one more overall remark on this framework.
It’s said to be a relief in GUI and tools pogramming after tenacious approaches so far. And I have no reasons to doubt that. I myself did struggle with MFC over 10 years ago. Since then I worked with excellent frameworks from various consortiums in the Java realm. Meanwhile I can deal with Juce, but still, this is a far cry from what I am used. And I don’t blame this on Jules and his superb one-man-achievement. I just thought things to be more developed in the C++ realm. Admittedly I am not into matters that much and hardly know the whole story. From where I come from (and this I consider to be Java after 10, no 12 years) I am used to way more solid, tiered and modal approches. But again I am not comparing Jules outstanding work with Java consortiums work - the professional achievement of countless companies or volunteers. But if JUCE is to better C++ GUI programming than the C++ realm itself has slept over the last 10 years.

And I don’t feel insulted if poeple can correct me on this. I welcome folks to broaden my sight.

Okay, enough philosophy, back to work.


Yes, I’m afraid C++ is just fundamentally much harder than Java!

Java makes it very easy to deal with libraries because of its excellent package-based design, but in C++ you’ve just got a big heap of code, and it’s up to the user to figure out how to structure it. One of my main reasons for creating Juce in the first place was that when you’re trying to write a complex C++ app, you generally need to collect together and link a whole bunch of random, incompatible 3rd party libraries, and I figured that I’d try to find a way to contain all that nightmarish mess in one self-contained lump, away from the application. If you think Juce is hard to get started with, just try writing a cross-platform app without it!

I’ve done my best to make it all run ‘out-of-the-box’, but it’s an ongoing project, and hopefully with the new Jucer it’ll all suddenly become much easier.

It’s quite helpful if beginners let me know about any errors they hit when they first try to run, because there could be simple things I could change or explain better to avoid them. Having got my own machine into a state where everything works perfectly, it’s hard to know exactly what setup is needed on a fresh install.


I spent 2 and half years working on C++ and Juce. Recently I shifted to Java. There have been several occasions in the last 4 months when I felt juce and C++ were much easier to work with. But I also know that, the reason for this is that I had spend all of my time working on C++ and not Java.

In your case it is the other way round. Accept what is available in juce. Because if you start using plain C++, Coding would be lot harder than what it is now. It’s just that you are not used Juce and C++. Keep your chin up continue working and few months down the line you would be comfortable with Juce.


I’m totally new to JUCE and to C++ to certain extends. I’m currently rewriting Myo Mapper in JUCE. Is there any way to use the native menu bar in OS X? Or the only option is to create a MenuBar within the main component as showed into the demo?



Check out MenuBarModel::setMacMainMenu
I think there’s an example of this in the Demo and you can switch between the two modes.


Thanks dave! I’ll have a look at it. However I found a very nice example on the book Getting Started With JUCE, which unfortunately is outdate :frowning:


Hi Dave, I had a look at the example I’ve reimplemented my menuBar following the Demo but now I’ve got a problem. It seems to call the menuItemSelected function only when I press the menuItem a second time.

HERE the code where I do select the menuItem. I guess it should work just fine.



I just checked the code for that example (Chapter05_04) and it still works in the latest JUCE. The structure of JUCE modules has changed since the book was published, but a simple way to get it to work is to create a new GUI Application project in the Projucer and copy the Source directory from the book example replacing the code in the newly-created example.