0

I'm trying to take the value entered in a jTextField, parse it, then use it to calculate an output.

In every other application I've used this is really simple. There is some form of event that will trigger when the text is changed, and I can use that event to perform the actions I want. In netbeans though, no such luck. The closest to an on changed event I could find was InputMethodTextChanged, which doesn't seem to work how I think it does.

Every resource online says to use a documentListener, but no resource that I can find actually gives information on how to use it. I'm sure for an experienced programmer the information provided is more than enough, but an experienced programmer already knows how to use it.

Could somebody please explain how DocumentListener works, and how to use it clearly enough for a novice programmer to understand? Stack Overflow always shows up quickly in Google Searches, and at the moment there is no newbie friendly source of information on this that is easy to find, if at all.

Space Ostrich
  • 413
  • 3
  • 5
  • 13
  • [This question and its answers](http://stackoverflow.com/questions/3953208/value-change-listener-to-jtextfield) might help – Arjan Jun 13 '16 at 04:15
  • That was one of my sources. I'm sure it's accurate and helpful to anybody who already knows how it works, but for me, that's not helpful. Apparently your text fields have a "document" that is already created. Some other answers show people creating a new document. The "document" is never explained. Hell, I don't even know where to put that code. I've got that basic code block in my program, no idea where it's supposed to go. It doesn't give me any errors anymore, but it also doesn't do anything. – Space Ostrich Jun 13 '16 at 04:43

1 Answers1

1

I know the answer comes very late, but for other people who will try to find the answer of this issue, please have a look here: https://netbeans.org/bugzilla/show_bug.cgi?id=14364. At this moment (NetBeans 8.2) this is still not implemented and the only way is to edit the source code yourself.

jTextField1.getDocument().addDocumentListener(new DocumentListener() { @Override public void insertUpdate(DocumentEvent e) { } }

Hope this helps.