Roman
Roman

Reputation: 131088

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.

Upvotes: 1

Views: 290

Answers (2)

Geo
Geo

Reputation: 96827

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

Upvotes: 1

oneat
oneat

Reputation: 10994

So you should read something about JFrame and JTextField and after (Add)ActionListeners (function in JTextField) in java and File Streams like FileInputStream and FileOutputStream. It's very easy !

Upvotes: 1

Related Questions