I am a beginner to Java. I am making a simple text editor in netbeans 7(.3) IDE, using its GUI editor. The main problem I face in it is that I can't make it to save/open the file. I have created the "save" button. When I drop the file chooser, it comes as a normal open file dialog box embedded in the java window with no functionality at all. I have also tried creating a new jFileChooser when the save button is clicked (in the Source view), but it doesn't work.
In a nutshell, I need a simple open/save dialog box. When the "Save" button is pressed, the save dialog box opens and saves the file wherever the user chooses with whatever name and .rtf or .txt extension. (P.S.: is it possible to save a file in .docx or .doc in Java?)
When the "Open" btn is pressed, it opens a file in .rtf or .txt (again, is it possible to open .docx or .doc in Java?) through the file chooser.
private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {
JFileChooser saveFile = new JFileChooser();
if saveFile.showSaveDialog(modalToComponent) == JFileChooser.APPROVE_OPTION {
File xyz = saveFile.getSelectedFile();
}
}
Code is here: https://docs.google.com/file/d/0B766zz1iJ1LRN2lGRjNtM29vN2M/edit?usp=sharing