开发者

Showing popup menu to menu item

My problem is this

I want to show a popup menu 开发者_StackOverflow社区to a menu item in java, this i can easily achieve,

but when i am showing the popup menu the parent menu clears,

behaviour i want is parent menu also should be visible while showing popup menu


May I first ask "why"? It seems like very uncommon, thus bad usability. There's a good reason why you don't see this in any main stream application. If you want submenu, use submenu like trashgod's sample.

You can add a PopupMenuListener to your parent menu's popup menu, break at popupMenuWillBecomeInvisible and see the call stack. In JDK6, It comes from BasicMenuItemUI#doClick calling MenuSelectionManager#clearSelectedPath.

So if you really have a good reason to surprise user, supply your own menu item UI.


I'm looking at two demos, PopupMenuDemo and GraphPanel, and I don't see any clearing. PopupMenuDemo shows a hierarchical submenu, while GraphPanel shows a hierarchical context menu. Do you have an example in which "the parent menu clears."

Addendum: Here's what I see for PopupMenuDemo. Neither demo appears to invoke setVisible() on the menu.

Showing popup menu to menu item

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜