Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JMenubar on a fullscreen JFrame (Mac OS)  RSS feed

 
Martin Mueller
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Ranchers,

I've been struggling with a relatively basic and generic Java problem for months now, and after striking out on every other source I could find on the net, I knew it was time to go to the ranch.

My application has a JMenuBar attached to a JFrame and runs smoothly on Windows. But when I run the exact same code on the Mac (10.7), the JMenuBar simply stops working. The individual JMenus can still be clicked and are being highlighted, but neither a mouseover nor a click unfolds them to reveal the underlying JMenuItems.

I'm using a BufferStrategy, but that doesn't seem to be the problem, because it works fine otherwise. Rather, the fact that the JFrame is being set to fullscreen (via the GraphicsDevice object) appears to be the cause of the troubles. I don't want to use the Mac menubar (for reasons related to the nature of the application, please take that as a given), but the regular JMenuBar on an individual JFrame (just like it's being done on Windows).

So, my question is this - how can I put a JMenuBar on a JFrame that is being set to fullscreen on a Mac?

Thanks a lot for your attention and - possibly - your help,

Martin
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

...the JMenuBar simply stops working. The individual JMenus can still be clicked and are being highlighted, but neither a mouseover nor a click unfolds them to reveal the underlying JMenuItems.

Difficult to say based on the information you have provided. Did you try running the application from the command line? That way you will be able to observe exceptions (if any) on the console, which might lend a clue.
You might also want to test with some other application running on full screen mode which has sub menu items. That way you can isolate if it's your code problem or the OS problem.
 
Martin Mueller
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey Maneesh,

thank you for your answer.

I develop and run the code from within Eclipse, doing it from the console leads to the same result. Also, I wrote a skeleton app with a fullscreen JFrame and a JMenuBar attached to it, and again, it worked fine on Windows but the menubar remains non-reactive in a Mac environment (10.7).

Since I keep reading that Apple encourages developers to use the Mac menubar, I was wondering whether that also meant the conventional way of putting a JMenuBar on an individual JFrame simply doesn't work on a Mac like it does on Windows, especially when that JFrame is put to fullscreen.

So I guess my general question would be, whether a JMenuBar can be attached to a fullscreen JFrame on a Mac. If the answer is yes, I know there's something wrong with my OS. If, however, the answer should be no, I simply don't need to bother and will go for the Mac menubar right away.

Thanks again,

Martin
 
Maneesh Godbole
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Unfortunately I haven't written an Swing code specifically for Macs so cannot really offer any assistance on that part.
However I would recommend going through the multiple Mac+Swing related links here http://www.coderanch.com/how-to/java/MacOsxFaq that might provide you more insight on the problem
Also check out https://developer.apple.com/library/mac/documentation/java/conceptual/java14development/04-JavaUIToolkits/JavaUIToolkits.html
 
Martin Mueller
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'll do that. Thank you very much for your time and help.

M
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!