简体   繁体   中英

Showing popup menu to menu item

My problem is this

I want to show a popup menu 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

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.

替代文字

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM