This content has been marked as final. Show 4 replies
Try calling setMenuBar(null) on the Frame that houses the MenuBar, to remove the MenuBar.
But may I ask why you are laboring over an AWT GUI in this day and age? Why not Swing?
edit Misread the requirement, sorry
edit2 I've played around a bit with this and come to the conclusion that the AWT MenuBar is a native component and any approach to fulfill this requirement would be at best cumbersome, probably involving JNI/JNA, and at worst buggy and error-prone. I'll stand corrected if anyone can provide a pure Java implementation... one way might be by using Robot to click the mouse at the appropriate location, but I don't see any getLocation / getLocationOnScreen methods either.
In Swing, it's not difficult, JMenu#doClick() will do it.
Edited by: DarrylBurke
The need is to support those who still use AWT controls and simulate the action of clicking the AWT menubar - we were earlier using the native way to do the same but on Linux this is proving difficult with Java changing it's dependencies on XToolkit and Motif - so I was looking for a not-native-way of doing the same.