• 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

Opening JInternalFrame on JMenu selection

 
Sheriff
Posts: 9689
42
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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...
 
Ranch Hand
Posts: 4632
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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)

 
Ankit Garg
Sheriff
Posts: 9689
42
Android Google Web Toolkit Hibernate IntelliJ IDE Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Use both Mnemonics and Accelerator, why didn't I think of that .

Thanks Michael
 
reply
    Bookmark Topic Watch Topic
  • New Topic