Code For notepa-WPS Office
Code For notepa-WPS Office
package notepad;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.Scanner; \
import java.io.*;
public Notepad() {
this.setSize(500, 300);
setDefaultCloseOperation(EXIT_ON_CLOSE);
this.getContentPane().setLayout(new BorderLayout());
this.getContentPane().add(textArea);
this.setMenuBar(this.menuBar);
this.menuBar.add(this.file);
this.file.setLabel("File");
this.openFile.setLabel("open");
this.openFile.addActionListener(this);
this.file.add(this.openFile);
this.saveFile.setLabel("Save");
this.saveFile.addActionListener(this);
this.file.add(this.saveFile);
this.close.setLabel("Close");
this.close.addActionListener(this);
this.file.add(this.close);
if (e.getSource() == this.close)
this.dispose();
if (option == JFileChooser.APPROVE_OPTION) {
this.textArea.setText("");
try {
while (scan.hasNext())
this.textArea.append(scan.nextLine() + "\n");
System.out.println(ex.getMessage());
if (option == JFileChooser.APPROVE_OPTION) {
try {
out.write(this.textArea.getText());
out.close();
System.out.println(ex.getMessage());
}
}
app.setVisible(true);