• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

F1 Key not working in java HelpSet

 
Balasubramanian Chandrasekaran
Ranch Hand
Posts: 215
Firefox Browser Linux VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need help in figuring out context-sensitive help(CSH).I am building a swing application which operates in two modes (Normal and Fullscreen).In that one i kept a class which handles KeyListener.

My problem is Whenever i press F1 key in Normal Window mode i can able to get CSH loaded.The same code doesn't work in Fullscreen mode.

Here is the code for the keyPressed event



Can anyone point me where i gone wrong?
 
Harish Kashyap
Ranch Hand
Posts: 118
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It doesn't necessarily mean that your program has some error. As I do not see any problem with the function you have written.
Working with swings has always been tricky because they bahave differently on different platforms(OS). They inherit the native windowing capabilities from the underlying operating system.
I would suggest you to add some debug prints and firstly figure out whether this function is at all getting invoked in full screen mode?
Secondly, if your window does not gain focus, then the key press events may not get captured by your program.
 
Balasubramanian Chandrasekaran
Ranch Hand
Posts: 215
Firefox Browser Linux VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Harish Kashyap:
It doesn't necessarily mean that your program has some error. As I do not see any problem with the function you have written.
Working with swings has always been tricky because they bahave differently on different platforms(OS). They inherit the native windowing capabilities from the underlying operating system.
I would suggest you to add some debug prints and firstly figure out whether this function is at all getting invoked in full screen mode?
Secondly, if your window does not gain focus, then the key press events may not get captured by your program.


Hi Harish,

I use eclipse for building my application and i inserted breakpoints inside that keyPress method and then i tried to debug it.Actually, that function gets called in both the cases(Normal and Fullscreen).But, i cannot see the help. One more thing is that i kept other shortcut keys also (like Shift+F4 which is used to toggle between Normal and Fullscreen) which are working well in Fullscreen mode.Only problem i am getting is inside this F1 key event only.
 
Balasubramanian Chandrasekaran
Ranch Hand
Posts: 215
Firefox Browser Linux VI Editor
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here i managed to get the code working by just adding one statement to the code and my resultent code is



But now my problem is whenever i press F1 key i am getting help loaded on the screen with multiple instance(i.e.,) For every F1 key press i loads new Help frame instead of displaying already loaded frames.
Now where i have to change my code to make it appear only once.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic