Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Two menu function differences when useScreenMenuBar set



On Sep 1, 2008, at 6:42 AM, Bob Jacobsen wrote:

I've encountered two changes in menu behavior when the apple.laf.useScreenMenuBar property is set to true. I'd like a little Accumulated Wisdom on what to do about them.

1) menuSelected isn't called the first time when useScreenMenuBar is true.

I've got a menu that implements MenuListener to dynamically create its contents in the menuSelected method. This works great when useScreenMenuBar isn't set. When it is, if the menu is selected right after the associated JFrame is first displayed, before anything else (any other window, background, etc is clicked), menuSelected isn't invoked.

It's as if the menu is created in the selected state, and isn't going to go there until the window first loses focus.

The workaround is to manually setSelected(true);setSelected(false) at the end of the menu's ctor. Crude, but seems to be effective. Unfortunately, the reason I want this menu to be dynamic is that it's expensive to populate, and seldom invoked. Creating it in the ctor defeats the purpose of a dynamic menu, at least for this one.

Is there any other solution to this?

At present, no - but we have several enhancement requests for this.

2) JButton in the JMenu doesn't display

To display a (occasionally changing) icon in the menu bar, I add a JButton to the JMenu. The JButton has no text, just an icon, though that doesn't seem to effect the problem. On other platforms, on the Mac with non-Aqua LAF, and in Aqua when useScreenMenuBar isn't set, this works. When useScreenMenuBar is set, the JButton just doesn't display. There _might_ be a couple of pixels of width being reserved for it or not, its hard to tell. But the icon is clearly not there, and if I use text instead, it's not there either.

I've found no workaround for this, and would greatly appreciate one. Even an explanation of why it's happening would be very helpful.

The "screen menu bar" menus are really just AWT menus that were generated from properties plucked off of Swing menus (like title, icon, keyboard shortcut, etc). We currently don't take arbitrary component hierarchies and render them in the native menus, because (1) it's hard, and (2) what would come out would most likely be Aqua HIG non-compliant.


When you opt-into "useScreenMenuBar", you are opting into Mac platform- specific behavior, which is not going to provide you full cross- platform fidelity (and that's why we have it off by default). Even if we redesign the screen menu bar to support arbitrary notifications, and a "default menu" if no windows are open, we will still likely keep it on top of (slightly enhanced) AWT menu peers.

Hope this helps explain what you are seeing,
Mike Swingler
Java Runtime Engineer
Apple Inc.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden

This email sent to email@hidden
References: 
 >Two menu function differences when useScreenMenuBar set (From: Bob Jacobsen <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.