Code for Click event and Enter key event in Netbeans
by Preetha[ Edit ] 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());
}
})