Put this private class into your public class. Just like a method.
private class textChangedListener implements KeyListener
{
public void keyPressed(KeyEvent e){}
public void keyReleased(KeyEvent e){}
public void keyTyped(KeyEvent e)
{
System.out.print(textField1.getText());
}
}
And then call it to your JTextField
in your main method like so:
private JTextField textField1; // just showing the name of the JTextField
textField1.addKeyListener(new textChangedListener());