Reputation: 167
is there any editor in Java? To expand that, want to - let's say - open a text file, edit it, and then save it back or cancel?
What I want to do is that I have a GUI and I want to click a button that will bring up the file chooser, then I choose my text file that will be opened using this editor, I will then edit the file and finally save it or cancel to not save the changes, which will return me back to my GUI.
I would like to do all of these while in the Java environment, closing the GUI, editing the file and then reopening can be easily done.
Upvotes: 2
Views: 320
Reputation: 324207
that will allow them to edit their strategy on the run
I don't know much about games, but why would the "strategy" be expressed in a text file? I would think you would want to use check boxes or radio buttons or combo boxes to allow the user to alter the strategy by selecting keywords etc. Then your could store the strategy is a Properties file.
A text editor would not allow for editing of the text for valid values or key works. So if the user entered "abcd" I'm sure that would be just garbage. If all you want is text then a JTextArea should work just fine, since I don't see that you need any need for highlighting or bolding of the text. A text area supports the ability to read() and write() the contents from and to a file directly.
What are the exact feature you expect this "text editor" to provide?
Upvotes: 0
Reputation: 7070
If you are Trying to make your own editor, Its a big process. You got to construct your UI, (1 big text area) set up a file chooser.
Basically use a JFrame
with a JTextArea
JFileChooser
Upvotes: 1