This post is from a low-reputation account and contains an unverified outbound link. Be cautious before clicking external links.

Java Programming : Event Handle by Using Keyboard

Words
115
Reading
1 min
Listen
Play
8y

What Will I Learn?

  • We will learn the concept of Event Handle in Java programming

Requirements

-Java Development Kit (JDK) must be installed.

-Also the computer system must have Java IDE installed. Probably Netbeans.

Difficulty

  • Intermediate

Tutorial Contents

we are going to learn the events handling in Java programming. Sometime, the users prefer clicking by using the keyboard than using the mouse. The sum operation can be done by entering keyboard below. The code is added is

if(e.getKeyCode()==e.VK_ENTER)

the full code below

private void resultKeyPressed(java.awt.event.KeyEvent evt) {                                  
        // TODO add your handling code here:
        if(e.getKeyCode()==e.VK_ENTER)
{
int x=Integer.parseInt(data1.getText());

int y=Integer.parseInt(data2.getText());
String z=String.valueOf(x+y);
result.setText(z);
}

    }                    

The result is displayed in picture below
jv.jpg

my project is in github

Curriculum

This is my first tutorial about Java programming



Posted on Utopian.io - Rewarding Open Source Contributors

Java Programming : Event Handle by Using Keyboard | Ecency