Forums Register Login

JPopupMenu or JMenu - neither is quite what I'm after.

+Pie Number of slices to send: Send
I'd like a little popup menu to appear when I click on a button, I would like the menu to highlight the background of each menu item as the mouse moves over it.

This doesn't happen with a JPopupMenu, it works with a JMenu but I can't figure out how to trigger the menu without having a JMenuBar.

So, is there a way of making the JPopupMenu highlight elements? Or way to create a JMenu without a menu bar?

I've tried, menu.doClick(0); but that only works when the menu bar is also present.
+Pie Number of slices to send: Send
That's odd. When I run the PopupMenu Demo from the How to Use Menus tutorial, it behaves exactly the way you say you want it to behave.
+Pie Number of slices to send: Send
When running that sample code I can't seem to see a popup menu, just the two menus at the top.

http://img522.imageshack.us/img522/6218/menuk.jpg

My code (below) works but the menu items don't highlight when I move the mouse over each menu item.
+Pie Number of slices to send: Send
 

Harold Lime wrote:When running that sample code I can't seem to see a popup menu, just the two menus at the top.



Um, you right-click the blank area and you get a popup menu.
+Pie Number of slices to send: Send
Fixed.

It seems that not supplying a component to:



stops the menu items from highlighting.

Thanks
+Pie Number of slices to send: Send
Hmm. That wouldn't have been my first guess. Or even in the top ten guesses. Anyway glad you got it fixed.
+Pie Number of slices to send: Send
 

Harold Lime wrote:Fixed.

It seems that not supplying a component to:

  • JPopupMenu.show(Component invoker, int x, int y)

  • stops the menu items from highlighting.



    FYI, you may continue to use setVisible(true) if you simply call popup.setInvoker(button) first.
    Let's get him boys! We'll make him read this tiny ad!
    a bit of art, as a gift, the permaculture playing cards
    https://gardener-gift.com


    reply
    reply
    This thread has been viewed 3489 times.
    Similar Threads
    Way to share JMenuItems with JMenus and JPopupMenu?
    JPopupMenu
    JPopUp
    JMenuItem question
    A serious JPopupMenu Problem Help!
    More...

    All times above are in ranch (not your local) time.
    The current ranch time is
    Mar 28, 2024 22:55:28.