Micro Project Proposal Notepad Clone': Aims/Benefit of The Micro Project (Minimum 30-50 Words) : 1. Aims
Micro Project Proposal Notepad Clone': Aims/Benefit of The Micro Project (Minimum 30-50 Words) : 1. Aims
1. Aims:
To develop Notepad Clone using Advanced Java Programming.
2. Benefits:
1. Java concepts are cleared using this microproject.
a. Select one topic for a micro project that you find very simple.
b. Consult with your teacher for finalization of the topic.
c. Make a draft copy of the micro project proposal.
d. Take approval from the teacher.
e. Make a list of resources required such as raw material, instruments,
software.
f. Execute Micro project.
g. Test Micro project.
h. Observe outputs/Results of Micro projects.
i. Prepare Micro Project Presentation.
j. Prepare Micro project report for submission
1
➢ Action Plan:
1. Resource Required:
2
➢ Abstract:
This application is a text editor in JAVA. This text editor developed in a JAVA
platform replication of the word editors we all are familiar with and which we
use quite often on daily basis. The only difference being that, this editor has been
created using JAVA for the front-end interface. The text edited in the editor is
stored in the desired location.
Friendly easy to use interface – This notepad editor is easy to use, just like any
other text editor (MS Word, Notepad etc)
1. Aims:
To develop Notepad Clone using Advanced Java Programming.
2. Benefits:
1. Advanced Java concepts are cleared using this micro project.
➢ Literature Review:
Sr. No Reference Links
1. Concepts about swing https://www.javatpoint.com/javaswing
III. Outputs of the Micro project (Presentation of data, findings, drawing etc.):
Program Code: -
4
Notepad Clone:
package JavaApplication9;
import java.awt.*; import
java.awt.event.*; import
javax.swing.*; import
java.io.*;
import javax.swing.filechooser.*;
public class JavaApplication9 extends JFrame implements ActionListener {
private JTextArea area; private JScrollPane scpane; String text = ""; public
JavaApplication9() { super("Notepad"); setSize(900, 800); setLayout(new
BorderLayout()); JMenuBar menuBar = new JMenuBar();
JMenu file = new JMenu("File");
JMenuItem newdoc = new JMenuItem("New");
newdoc.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N,
ActionEvent.CTRL_MASK)); newdoc.addActionListener(this);
JMenuItem open = new JMenuItem("Open");
open.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O,
ActionEvent.CTRL_MASK)); open.addActionListener(this);
JMenuItem save = new JMenuItem("Save");
save.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,
ActionEvent.CTRL_MASK)); save.addActionListener(this);
JMenuItem print = new JMenuItem("Print");
print.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_P,
ActionEvent.CTRL_MASK)); print.addActionListener(this);
JMenuItem exit = new JMenuItem("Exit");
exit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, 0)); JMenu
edit = new JMenu("Edit");
JMenuItem copy = new JMenuItem("Copy");
copy.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C,
ActionEvent.CTRL_MASK)); copy.addActionListener(this);
JMenuItem paste = new JMenuItem("Paste");
paste.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V,
ActionEvent.CTRL_MASK));
paste.addActionListener(this); JMenuItem
cut = new JMenuItem("Cut");
cut.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X,
ActionEvent.CTRL_MASK)); cut.addActionListener(this);
JMenuItem selectall = new JMenuItem("Select All");
selectall.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A,
ActionEvent.CTRL_MASK));
selectall.addActionListener(this);
5
JMenu about = new JMenu("Help");
JMenuItem notepad = new JMenuItem("About Notepad");
notepad.addActionListener(this); area
= new JTextArea();
area.setFont(new Font("SAN_SERIF", Font.PLAIN, 20));
area.setLineWrap(true);
area.setWrapStyleWord(true); scpane
= new JScrollPane(area);
scpane.setBorder(BorderFactory.createEmptyBorder());
setJMenuBar(menuBar);
menuBar.add(file);
menuBar.add(edit);
menuBar.add(about);
file.add(newdoc); file.add(open);
file.add(save); file.add(print);
file.add(exit); edit.add(copy);
edit.add(paste); edit.add(cut);
edit.add(selectall);
about.add(notepad); add(scpane,
BorderLayout.CENTER);
setVisible(true);
}
public void actionPerformed(ActionEvent ae) { if
(ae.getActionCommand().equals("New"))
{ area.setText("");
} else if (ae.getActionCommand().equals("Open")) { JFileChooser
chooser = new JFileChooser("D:/Java");
chooser.setAcceptAllFileFilterUsed(false);
FileNameExtensionFilter restrict = new FileNameExtensionFilter("Only .txt
files",
"txt");
chooser.addChoosableFileFilter(restrict); int
result = chooser.showOpenDialog(this);
if(result == JFileChooser.APPROVE_OPTION) {
File file = chooser.getSelectedFile(); try{
System.out.println("HEki");
FileReader reader = new FileReader(file);
BufferedReader br = new BufferedReader(reader);
area.read( br, null ); br.close();
area.requestFocus(); }catch(Exception e){
System.out.print(e);
}
6
}
} else if(ae.getActionCommand().equals("Save")){
final JFileChooser SaveAs = new JFileChooser();
SaveAs.setApproveButtonText("Save"); int
actionDialog = SaveAs.showOpenDialog(this);
if (actionDialog != JFileChooser.APPROVE_OPTION) { return;
}
File fileName = new File(SaveAs.getSelectedFile() + ".txt");
BufferedWriter outFile = null;
try {
outFile = new BufferedWriter(new FileWriter(fileName));
area.write(outFile); } catch (IOException e)
{ e.printStackTrace();
}
}else if(ae.getActionCommand().equals("Print")) {
try{ area.print();
}catch(Exception e){}
}else if (ae.getActionCommand().equals("Exit")) {
System.exit(0);
}else if (ae.getActionCommand().equals("Copy")) { text
= area.getSelectedText();
}else if (ae.getActionCommand().equals("Paste")) {
area.insert(text, area.getCaretPosition()); }else if
(ae.getActionCommand().equals("Cut")) {
text = area.getSelectedText();
area.replaceRange("", area.getSelectionStart(), area.getSelectionEnd());
}else if (ae.getActionCommand().equals("Select All")) { area.selectAll();
}else if (ae.getActionCommand().equals("About Notepad")) {
}}
public static void main(String[] args)
{
new JavaApplication9();
new JavaApplication9().setVisible(true);
}
}
Output: -
7
8
9
8.0 Skill developed / Learning outcome of the Micro-Project:
1. Communication
skills.
2. Time management. 3.
Working in a team.
4. Following ethics.
5. Stress management.
6. Psychomotor skills such as making documents and demonstrating them.
7. Presentation skills.
10