I have a JTextField
and a JButton
, when user hits enter on the JTextField
then action has to be performed on the corresponding JButton
. Here is my code snippet.
Also i want to disable the JButton
on enter and enable it later when something is changed in the JTextField
JButton jb=new JButton("Print");
JTextField jt=new JTextField(20);
jb.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent ae)
{
System.out.println(jt.getText());
}
});