Problems with I/O

I am writing a simple word processor similar to Notepad in function, but am having problems with the opening the files. The "open" window appears to allow you to select the .txt file, but nothing is displayed in the new "OPEN" window from the file. What I want is the file to appear in the JTextArea like it would appear in Notepad, not in a new window. Also, how would you go about setting shortcut keys for the menu items, ie. Cntrl+S for save, etc. I think "setAccelerator" will work, but I don't know how to define the keystroke part. I have enclosed the code to aid in any assistance. You can e-mail me at insanity@arrakis.es
Also, how would one go about setting up cut and paste operations where you can highlight the text and do a cut/copy and paste. Thanks for any help!

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
import java.io.*;

public class MyWordPad {

JTextArea editArea;

//------------------------constructor

public MyWordPad() {
// Create a new panel for drawing, with mouse and key listeners.

JPanel content = new JPanel();
content.setLayout(new BorderLayout());

//--------------------create text area with properties

/*JTextArea*/ editArea = new JTextArea(40,80);
editArea.setLineWrap(true);
editArea.setWrapStyleWord(true); //enables line wrapping for specified window size
// content.add(editArea,BorderLayout.CENTER);

//-- Create a new window
JFrame mw = new JFrame("MyWordPad");
// Add a listener to the window's close box.
mw.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0); // Stop the program
}
});
mw.setSize(600,400); // Set the size of the window
mw.setContentPane(content); // set the content of the window.
mw.setVisible(true); // Make the window visible


//--------------------Menu Bar

JMenuBar myMenuBar = new JMenuBar();
mw.setJMenuBar(myMenuBar); //add menubar to frame

JMenu fileMenu = new JMenu("File");
myMenuBar.add(fileMenu); //add File menu to menubar

JMenu editMenu = new JMenu("Edit");
myMenuBar.add(editMenu); //add Edit menu to menubar

//-----------------------File menu
JMenuItem clearItem = new JMenuItem ("New");
fileMenu.add(clearItem);
clearItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {

}
});//clears window for new document

JMenuItem openItem = new JMenuItem ("Open");
fileMenu.add(openItem);
openItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JFrame openWindow = new JFrame("Open");
openWindow.setSize(600,350); //set openFile window size
openWindow.setContentPane(editArea);

JFileChooser fileChooser = new JFileChooser();
fileChooser.setDialogTitle("");
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
fileChooser.setApproveButtonText("Open");
fileChooser.setApproveButtonToolTipText("Open");
int myReturnVal = fileChooser.showOpenDialog(openWindow);
if (myReturnVal == JFileChooser.APPROVE_OPTION) {
File myFile = fileChooser.getSelectedFile(); //read the file
}

//setAccelerator(Keystroke CTRL_O);
openWindow.setVisible(true);

}
});

content.add(editArea,BorderLayout.CENTER);

JMenuItem saveItem = new JMenuItem ("Save");
fileMenu.add(saveItem);
saveItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
JFrame openWindow = new JFrame("Save");
openWindow.setSize(200,200); //set openFile window size
// openWindow.setContentPane(content);

JFileChooser fileChooser = new JFileChooser();
fileChooser.setDialogTitle("Save");
fileChooser.setFileSelectionMode(JFileChooser.FILES_ONLY);
fileChooser.setApproveButtonText("Save");
fileChooser.setApproveButtonToolTipText("Save:");
int myReturnVal = fileChooser.showSaveDialog(openWindow);
if (myReturnVal == JFileChooser.APPROVE_OPTION) {
File myFile = fileChooser.getSelectedFile(); //read the file
}
openWindow.setVisible(true);

}
});

JMenuItem exitItem = new JMenuItem ("Exit");
fileMenu.add(exitItem);
exitItem.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.exit(0);
}
});//listens for exit button

mw.setVisible(true); // Make the window visible
[5091 byte] By [developer-network] at [2007-11-15 20:12:23]