Okay I'm stuck at a little problem. I'm creating a desktop application which uses JDesktopPane and JInternalFrame. Now the main window which contains these internal frames has a menu bar. Some of the menu's don't have any options in them. Instead I have to open a JInternalFrame when the menu is clicked (I know it sounds a little weird but I can't help it). I did it using menuListener on the JMenu. The problem is that the JInternalFrame doesn't gets focus as the empty menu has the focus. I tried to get focus in the internal frame using requestFocus, grabFocus, and setSelected but none worked (I called these methods after the internal frame was visible as I read that they don't work before the frame is visible). As an alternative I tried to add JMenuItem to JMenuBar, it took the full width which I controlled using setMaximumSize. The internal frame is getting focus but the problem in this case is that the shortcut key that I set for this menu item (using setMnemonic) doesn't work. Does anyone know how to either get the internal frame to focus when using JMenu or get the shortcut to work if I put JMenuItem to JMenuBar...
worked OK for me, in a simple demo program.
setAccelerator seems to work OK when the menuItem is added directly to the menuBar (leaving setMnemonic to show the underlined shortcut key)