Lompat ke konten Lompat ke sidebar Lompat ke footer

Java getKeyCode

Java Using Get Key Code

KeyCode On KeyPress To Check Which Key Is Pressed Like  Java getKeyCode

In This Java Tutorial  We Will See How To Use getKeyCode On KeyPress To Check Which Key Is Pressed Like ENTER or SPACE In Java Programming Language And NetBeans Editor.


Source Code:

private void formKeyPressed(java.awt.event.KeyEvent evt) {                                
        
        int key = evt.getKeyCode();
        if(KeyEvent.VK_ENTER == key)
        {
            jLabel1.setText("Enter");
        }else if(KeyEvent.VK_SPACE == key)
        {
            jLabel1.setText("Space");
        }
        else
        jLabel1.setText(Integer.toString(key));
        
    }    
      
///////////////OUTPUT:

KeyCode On KeyPress To Check Which Key Is Pressed Like  Java getKeyCode

KeyCode On KeyPress To Check Which Key Is Pressed Like  Java getKeyCode




Posting Komentar untuk "Java getKeyCode"