JTextField function=new JTextField(8);
function.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
//statements!!!
}});
all you need to do is addActionListener to the JTextField like above! After you press Enter the action will performed what you want at the statement!