• Post Reply Bookmark Topic Watch Topic
  • New Topic

Issues with providing focus to keyboard buttons on a JInternalFrame

 
Alex Monari
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,

I'm having issues with providing focus to keyboard buttons when a JInternalFrame with keyboard buttons is called in my program. So for example when the program is started the attachment called signinscn.png is called.

This screen is a JDesktopPane which calls JPanel for its components.

From here a JInternalFrame containing the buttons ESC and F1 to F4 as seen in the attachment called signinscn.png is called.

I would like the buttons in my JInternalFrame to have focus such that when a user engages the equivalent keyboard button i.e. ESC or F1 to F4 WITHOUT clicking on the JInternalFrame the respective button's action listener kicks in. At the moment only after the user clicks on the JInternalFrame do the equivalent keyboard buttons respond.

Here's the constructor of my JInternalFrame and you can see how I handle the ESC keyboard button in the constructor of the JInternalFrame (but as I mentioned only after the user has engaged the JInternalFrame):



Any help is appreciated.

Regards,
Alex.

homescn.png
[Thumbnail for homescn.png]
signinscn.png
[Thumbnail for signinscn.png]
 
Rob Camick
Ranch Hand
Posts: 2699
10
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Looks to me like you are adding the KeyBindings to the root pane of the internal frame. This doesn't work because the internal frame doesn't have focus as you have noted.

I would guess you need to add the key bindings to the root pane of the JFrame.

If that doesn't work, then post a proper SSCCE that demonstrates the problem.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!