Professional Documents
Culture Documents
import java.awt.event.ActionEvent;
import java.io.FileReader;
import java.io.IOException;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JFileChooser;
import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.filechooser.FileFilter;
import javax.swing.filechooser.FileNameExtensionFilter;
import sun.security.action.OpenFileInputStreamAction;
//import sun.awt.AWTAccessor;
public coppp(){
fc.setFileFilter(textFiler);
setMenuBar(menuBar);
menuBar.add(file);
file.add(Open);
file.add(Save);
file.addSeparator();
file.add(Exit);
setDefaultCloseOperation(EXIT_ON_CLOSE);
pack();
setLocationRelativeTo(null);
setVisible(true);
// add action
@Override
if (fc.showOpenDialog(null) == JFileChooser.APPROVE_OPTION){
openFile(fc.getSelectedFile().getAbsolutePath());
};
saveFile();
};
@Override
System.exit(0);
};
FileReader fr = null;
try{
fr = new fileReader(fileName);
textArea.read(fr, null);
fr.close();
setTitle(fileName);
e.printStackTrace();
if (fc.showSaveDialog(null) == JFileChooser.APPROVE_OPTION){
Filewrite fw = null;
try{
textArea.write(fw);
fw.close();
e.printStackTrace();
new coppp();