• 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
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

setHelpMenu method of MenuBar

 
Ranch Hand
Posts: 2596
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was wondering what's the significance of setHelpMenu(Menu m) method of MenuBar class. RHE book says it should display the help menu in the right hand side of all the other menus. But when you try this code -

The menu named menu2 is at second position, which does not make method setHelpMenu() any different from add() method of MenuBar. Only if it is the last call, then the menu is set to the right, but that can be achieved with add() method as well.
Any other advantages of using setHelpMenu() ?
TIA,
- Manish
 
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I've experienced the same problem. What is weird is that the Menu class holds the help menu in a different reference than it holds the normal menus. All menus are stored in a Vector while the Help menu is stored in a Menu reference in order to treat it differently. What I've seen, though, is that on certain platforms the same code behaves differently. That is, sometimes the menu is added to the right of the menubar and sometimes not. This has nothing to do with when you invoke setHelpMenu(). You can invoke the latter method whenever you want to. The help menu will (should) be added on the right-most position (or on the left-most depending on the locale). My guess is that if it does not, then it must be the the look & feel that doesn't support that feature. I'll look into that.
 
Manish Hatwalne
Ranch Hand
Posts: 2596
Android Firefox Browser Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Valentin Crettaz:
The help menu will (should) be added on the right-most position (or on the left-most depending on the locale).


Yes! in fact that's what I thought, but it's surprisingly different. Anyway, thanks for all ur help. You are the best, as usual!!!
Regards,
- Manish
 
Valentin Crettaz
Author & Gold Digger
Posts: 7617
6
IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Moreover, pay attention to what follows. setHelpMenu() in java.awt.MenuBar does not really behave as expected and setHelpMenu() in javax.swing.JMenuBar is not implemented at all and will throw an error at runtime if invoked... What a shame! (Bug 4087846)
The following code has no functionality but shows the concept:

The execution yields:

Swing is not a SCJP2 objective, but this is good to know anyway.
[ March 17, 2002: Message edited by: Valentin Crettaz ]
 
She's brilliant. She can see what can be and is not limited to what is. And she knows this tiny ad:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
reply
    Bookmark Topic Watch Topic
  • New Topic