• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Liutauras Vilda
  • Ron McLeod
Sheriffs:
  • Jeanne Boyarsky
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Scott Selikoff
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
  • Frits Walraven
Bartenders:
  • Stephan van Hulst
  • Carey Brown

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

 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Sheriff
Posts: 28346
97
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Sheriff
Posts: 28346
97
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Fixed.

It seems that not supplying a component to:



stops the menu items from highlighting.

Thanks
 
Paul Clapham
Sheriff
Posts: 28346
97
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 986
3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
     
    Never trust an airline that limits their passengers to one carry on iguana. Put this tiny ad in your shoe:
    Smokeless wood heat with a rocket mass heater
    https://woodheat.net
    reply
      Bookmark Topic Watch Topic
    • New Topic