Code for Click event and Enter key event in Netbeans

by Preetha 2012-09-14 10:09:00

jButton1.addActionListener(new ActionListener()
{
@Override
public void actionPerformed(ActionEvent e)
{
jLabel1.setText("You searched for: "+jTextField1.getText());
}
});

jTextField1.addKeyListener(new KeyAdapter()
{
@Override
public void keyPressed(KeyEvent e)
{
if(e.getKeyCode() == KeyEvent.VK_ENTER)
jLabel1.setText("You searched for: "+jTextField1.getText());
}
})

Tagged in:

949
like
0
dislike
0
mail
flag

You must LOGIN to add comments