Search code examples
javauser-interfacetextareakeyevent

Java: How to immediately send changes in a text field to a file?


Is it hard to do the following with the Java? First I need to generate a window with a text field (no buttons, nothing, just a text field). Than, when a user types a symbol in the text filed, program immediately stores information about this in a file (which symbol was typed and when). That's it.


Solution

  • No, it's not hard. The following code snippet may get you running with the JTextField:

    http://www.java2s.com/Code/Java/Swing-JFC/TextfieldsandJavaevents.htm

    and this can help with writing to a file:

    http://www.java2s.com/Code/Java/File-Input-Output/WritelinesoftexttofileusingaPrintWriter.htm