Win a copy of Java Concurrency Live Lessons this week in the Threads forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

KeyListener Problem  RSS feed

 
Mohammed Ajmal
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Application was working fine and we upgraded to java1.4.2 and no changes done in java code. In my case, whenever user presses F1 key, the key event is getting handled correctly and it is opening help page.

But now the event is not getting captured even though there is a listener to catch.

Below is the code snippet.

------------------------


private void HelpKey()
{
try
{
java.awt.event.KeyListener keyListener = new java.awt.event.KeyAdapter()
{
public void keyReleased( java.awt.event.KeyEvent e )
{
// Check that the key released was F1
// and that some component was active
if ( getFocusOwner() != null && e.getKeyCode() == java.awt.event.KeyEvent.VK_F1 )
{ // Finally call the method in my controller and
// pass the active component as an argument
FormHelpURL( getFocusOwner() );
}

}
};
// add previously created listener to this window
addKeyListener( keyListener );
}


Could you please throw some light and give some pointers....

Thanks in advance.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!