File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes how to get focus on JMenuBar in JFrame Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "how to get focus on JMenuBar in JFrame" Watch "how to get focus on JMenuBar in JFrame" New topic
Author

how to get focus on JMenuBar in JFrame

harcharan kanwal
Ranch Hand

Joined: Jul 02, 2001
Posts: 64
hi all,
i am having trouble getting focus on JMenuBar in a JFrame at the start up of my application.i have tried
grabFocus()
requestFocus()
jMenuBar.setRequestFocusEnabled(true) in a Window opening event of window listener ,nothing seems to be working.
like to have some tips
thanks,
harcharan
harcharan kanwal
Ranch Hand

Joined: Jul 02, 2001
Posts: 64
i guess you can simple achieve it by pressing F10 key on the keyboard.if i am not wrong, do we specify keyboard operations on the application in our user documentation.
any comments
thanks
parthiban subramaniam
Ranch Hand

Joined: May 15, 2002
Posts: 116
hi,
why do you need to get the foucs on to the menubar anyways ??..i dont think any application does that when it start's up ..

hmm am not sure abut the f10 key it might be specific to windows ..
cheers,
parthi


Even crazy and silly looking problems are sometimes real.
harcharan kanwal
Ranch Hand

Joined: Jul 02, 2001
Posts: 64
i was just testing ,if somebody wants to use keyboard instead of a mouse,do you have any thoughts about this.yes i am developing on windows.any thoughts about this thought.
thanks
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi Harcharan,

So now if the user presses ALT+(mnemonic for parent menu)ALT+B or by simply pressing CTRL+B then the book item will be selected.
Hope this helps,
Michael Morris
[ September 25, 2002: Message edited by: Michael Morris ]

Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius - and a lot of courage - to move in the opposite direction. - Ernst F. Schumacher
harcharan kanwal
Ranch Hand

Joined: Jul 02, 2001
Posts: 64
hi Michael,
do we specify keyboard operations on the application in our user documentation.
thanks!
Michael Morris
Ranch Hand

Joined: Jan 30, 2002
Posts: 3451
Hi harcharan,

do we specify keyboard operations on the application in our user documentation.

I did and I think you would be remiss if you did not mention it.
Michael Morris
Valentin Crettaz
Gold Digger
Sheriff

Joined: Aug 26, 2001
Posts: 7610
Here is a list of supported key shortcuts for menus: http://java.sun.com/products/jlf/ed2/book/Appendix.A9.html
I recommend to read (or at least skim) through the (free) Java Look & Feel design guidelines. You may learn a lot about how to make usable and ergonomic GUIs. Also, the quality of the GUI you will produce with the kind of information contained within this book is far better than the one you would get from any IDE in my opinion.
This is not required for SCJD but if you are planning on taking your time anyway, why not reading this book.


SCJP 5, SCJD, SCBCD, SCWCD, SCDJWS, IBM XML
[Blog] [Blogroll] [My Reviews] My Linked In
harcharan kanwal
Ranch Hand

Joined: Jul 02, 2001
Posts: 64
thanks valentin ,surely look into this
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to get focus on JMenuBar in JFrame
 
Similar Threads
menu behaviour when resizing windows in Swing
how to restrict the focus between parent and child JFrame??
Focus problems...
JMenu
Closing Java Frame