Win a copy of Svelte and Sapper in Action this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

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

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Marshal
Posts: 25818
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Harold Lime
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Paul Clapham
Marshal
Posts: 25818
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Harold Lime
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fixed.

It seems that not supplying a component to:



stops the menu items from highlighting.

Thanks
 
Paul Clapham
Marshal
Posts: 25818
69
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hmm. That wouldn't have been my first guess. Or even in the top ten guesses. Anyway glad you got it fixed.
 
Author
Posts: 974
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
     
    Don't get me started about those stupid light bulbs.
      Bookmark Topic Watch Topic
    • New Topic