Fullscreen mode and keyboard acceleration

May 23, 2006

While working on Rad Image Viewer, I ran into an issue with keyboard acceleration in full screen mode.

By setting a keyboard accelerator for a JMenuItem, makes it possible to invoke the action without navigating through the menu. The action can be invoked by a keystroke. In short this is java speak for short cut keys. The trouble is keyboard accelerators work fine as long as you are not in full screen mode. The moment you get into full screen mode, short cuts are completely ignored.

Lot of hair pulling and Googling didn't lead to a solution. So Rad Image 0.91 was released without acceleration in full screen mode. Did another search today and was pleasently suprised to find a solution.

Halfway across the world a guy I know by his nick (afishionado) had encountered the same problem at the same time and fortunately for me found a solution. Even more fortunately he had taken the trouble to share it.

His solution is to use JFrame instead of JWindow. So why does the API and the sample codes all suggest the use of JWindow? The solution mentioned above suggests using undecorated JFrameS however the moment the decorations were removed accelerators stopped working.

An alternative to accelerators is to use a KeyListener. KeyListeners are more complicated and involve a bit of extra code. However I found that KeyListeners worked in full screen mode regardlesss of whether the frame is decorated or not. However they still failed with a JWindow was used instead of a JFrame.


Posted by raditha at May 23, 2006 12:52 PM
Your Ad Here

 

Jabber  |  Linux  |  mySQL  |  PHP  |  Java  |  Site Map  |  Wiki

Downloads  |  About  |  Links  |  Contact  |  Home

 

Copyright © Raditha Dissanayake 2003 - 2007

Terms of Use  |  Privacy

 

 

May 2006
Sun Mon Tue Wed Thu Fri Sat
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31