Keyboard Event Handling Mechanism in java


Now a day key events plays a major role in the application developing which help data application enter makes more fast and they are able to type the key event handling mechanism easily using their application.

Following are sample code of key event handling.

// Comment
private void jKeyPressed(java.awt.event.KeyEvent evt) {   

int a=evt.getKeyCode();
        if(a==10) // Enter Key
        {
         jTextFilednext.requestFocus();
        }
        else if(a==38) // up Arrow Key
        {
           jTextFiledPrevious.requestFocus();
        }
        else if(a==40) // Down Arrow Key
        {
        jTextFilednext.requestFocus();
        }


   if(a==37) // up left Key
        {
             jTextFiledPrevious.requestFocus();
        } else if(a==39) // up right Key
        {
            jTextFiledCurrent.requestFocus();
        } else if(a==10) // up Entert Key
        {
             jTextFilednext.requestFocus();
        }
raja P Web Developer

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...