Implementing an actionlistener to a JTextField

From what you’ve provided, it looks like you’ve imported or implemented a class other than java.awt.event.ActionListener named, ActionListener (class name conflict). Try qualifying the parameter as java.awt.event.ActionListener:

//Creates textField
JTextField input=new JTextField(20);
input.addActionListener(new java.awt.event.ActionListener() {
  public void actionPerformed(ActionEvent event) {
    direction=input.getText();
  }
});

Leave a Comment