Hello, I have a problem using setMnemonic for selecting menu items. For example, if I have a menu with two options 'File' and 'Edit' and under 'Edit' I define a 'Find' option, I set the keyboard mnemonics 'F' for the mnemonic for both 'File' and 'Edit'> 'Find'. Now here is the problem...When select 'Alt-E' the Edit menu is selected. Next, I select 'Alt-F' expecting to go to 'Find'. Instead, I go to 'File'. Is this the correct behavior ? I tried several window applications and when I use the 'Alt'-keypress, I stay on the same menu, not jump around. I know I can change the mnemonic for 'Find' and it works fine, but this is just an example of a bigger problem. Thanks in advance, -Mike Z.
"Mike Z", The Java Ranch has thousands of visitors every week, many with surprisingly similar names. To avoid confusion we have a naming convention, described at http://www.javaranch.com/name.jsp . We require names to have at least two words, separated by a space, and strongly recommend that you use your full real name. Please choose a new name which meets the requirements. Thanks.
the problem is not with setMnemonic() instead u r trying to navigate in a wrong manner. To go to Edit->Find menu u should use Alt+E followed by just F (not Alt+F).
Thanks, My only concern is even though this does work ( using 'Alt+E', then 'F'), this doesn't work the same as other windows applications. -Mike Z. [This message has been edited by Mike Z (edited February 27, 2001).]
Begging your pardon, unless I am reading what is happening wrong, that is the EXACT functionality of Windows Apps. If you are using IE, try this test. Alt-E (opens the Edit menu) now press F (it should take you to the find in page dialog box) Now try the same thing using your technique.. Alt-E opens edit menu (the same) Alt-F (opens File menu). I do know that some applications will have shortcuts to commands that are buried in a menu somewhere and its possible that is what you were thinking. Hope that helps...
Ryan Headley<br /><a href="http://www.sudovi.com" target="_blank" rel="nofollow">http://www.sudovi.com</a>
I'm having a similar problem to this one, in JDK 1.2.2 using swing. While Ryan is correct that mnemonics are single characters, i.e. Alt-F to activate the File Menu and 'n' to activate new, my users are complaining because the Alt acceleration is still active in the window even when the menu is open. For example: I have a menu (E)dit with three options Cu(t), (C)opy, and (P)aste. I also have a JButton (C)lose. If the user does everything correctly, they press Alt-E and 'c' to copy and Alt-C to close the window. If, though, they press Alt-E and Alt-C (forgetting to let go of the Alt key) the window closes. In IE, Netscape, and several Linux apps, I've found that once the menu pops up, the Alt key is either stripped or deactivated. In IE try Alt-F Alt-O, the open window is activated. I'm assuming IE is stripping the Alt key and passing along only the 'o'. Now try Alt-F Alt-T. Nothing happens because 't' is not a hot key on the file menu. Here I'm assuming the Alt key is thrown away or the (T)ools menu would be activated, at least, that's how my swing gui behaves. I've been trying to figure out a way to work around this by capturing the Alt key and discarding it as necessary, but haven't been able to get this to work. I'd really appreciate any advice you can give me.