Question: I would like the user to enter a value into the `JTextField` and use a listener to listen to the textfield and print the value to the console straightaway without pressing a key.

```
textfield1.addChangeListener(new ChangeListener() {
    public void actionPerformed(ActionEvent e) {                
        System.out.println(textfield1);
    }
});

```

error: 

```none
<anonymous textfield$2> is not abstract and does not override abstract method stateChanged(ChangeEvent) in ChangeListener

```

Answer: 
Yes, just use the KeyListener class, see the example below:

```
import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;

public class Main extends JFrame {
  public Main() throws HeadlessException {
    setSize(200, 200);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setLayout(new FlowLayout(FlowLayout.LEFT));

    JLabel label = new JLabel("Write something: ");
    JTextField input = new JTextField();

    input.setPreferredSize(new Dimension(100, 20));

    final JTextField output = new JTextField();
    output.setPreferredSize(new Dimension(100, 20));
    add(label);
    add(input);
    add(output);

    input.addKeyListener(new KeyAdapter() {
        public void keyReleased(KeyEvent e) {
            JTextField textField = (JTextField) e.getSource();
            String text = textField.getText();
            output.setText(text);
        }

        public void keyTyped(KeyEvent e) {

        }

        public void keyPressed(KeyEvent e) {
        }
    });
}

public static void main(String[] args) {
    new Main().setVisible(true);
}
}

```
You can set a addlistener to textproperty of the text field.

```
textField.textProperty().addListener(new ChangeListener<String>() {
            @Override
            public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
                System.out.println("textfield changed to "+ newValue);
            }
        });

```