Java getKeyCode
Java Using Get Key Code
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:
Posting Komentar untuk "Java getKeyCode"