Example 7

Text Editor

 

Create a simple text editor like the screenshot shown below. Use images instead of text to create buttons for loading and saving a file, as well as cut, copy and paste operations. Place the text area in a scroll pane so you can scroll through a document that is larger than the text area on the screen. Create a panel that allows text input for input and output filenames. Add OK and Cancel buttons to this panel. Keep this area disabled until the open or save buttons are pressed. After the open or save operation has been created, reset this area to a disabled state.

 

Create a class with two static methods, readInFromFile and writeToFile. The readInFromFile should only need the full path and filename to open, and should return the file using a String object. The writeToFile method requires two arguments, the full path and filename to save the data to, and the data to save as a String object.