0

I have a Swing program that uses JTextField's text to draw a string in canvas. The problem is it only does so after the entire text in the JTextField has been entered. How can I change the text in GUI dynamically, meaning each character that is being typed or deleted in JTextField is immediately drawn or deleted in GUI? I've already implemented MVC and have a bunch of actionListeners. Just not sure on what I should use the action listener for this. Scanner? Could somebody please point me in the right direction? Thank you.

  • Please refer to this thread [Value Change Listener to JTextField](https://stackoverflow.com/questions/3953208/value-change-listener-to-jtextfield) for details. – Eugene Dec 14 '17 at 08:21

1 Answers1

1

It's possible to use DocumentListener to reach the goal. The details is at Value Change Listener to JTextField

Changes like "insert", "remove" can be detected at the listener, no need to press Enter to trigger them.

Eugene
  • 10,627
  • 5
  • 49
  • 67