Note Pad
Note Pad
Note Pad
During the period of training his conduct was very good. He was sincere and
always ready to learn things and use them practically.
SUPERVISIOR
(Poonam Sehrawat)
NIIT
Najafgarh
ACKNOWLEDGEMENTS
Finally, I would like to express my gratitude to my family members for their moral
support and encouragement.
(Rohit Aggarwal)
PREFACE
This six weeks training is the part of four year degree course. It was really a great
experience to work in computer lab of NIIT , one gets an opportunity to see from
close quarters about the environment in which an engineer works.
We joined the computer lab of NIIT under the guidance of skilled and experienced
teachers in JAVA, we had learned a lot during the training and really enjoyed my
work at the laboratory.
Table of contents
S.No. Contents
1. NIIT
2. Abstract
3. Objective of the Project
4. Requirement Analysis
4.1 Need and Justification
4.2 Feasibility Study
4.3 Use Case Diagram
4.4 Flow Chart
4.5 System Requirement specification
5. System Design
6. Coding and snapshots
7. Software testing
8. Further Enhancement
9. References
NIIT
NIIT is a leading Global Talent
Development Corporation, building a
skilled manpower pool for global industry
requirements. The company which was set
up in 1981, to help the nascent IT industry
overcome its human resource challenges,
has today grown to rank among the
world’s leading talent development
organisations offering learning solutions to
Individuals, Enterprises and Institutions
across 40 countries.
NIIT Institute of Finance Banking & Insurance (IFBI), set up by NIIT with equity
participation from ICICI Bank, offers programmes for individuals and corporates in
the Banking, Financial Services and Insurance segments.
NIIT Institute of Finance Banking & Insurance (IFBI), set up by NIIT with equity
participation from ICICI Bank, offers programmes for individuals and corporates in
the Banking, Financial Services and Insurance segments.
NIIT Uniqua, Centre for Process Excellence, addresses the increasing demand for
skilled workers in the business and technology services industry by providing
training programmes in relevant areas. This initiative is a part of the NIIT Institute
of Process Excellence, a NIIT-Genpact joint venture.
Notepad is a basic text editor that can be used to create simple documents. The
most common use for Notepad is to view or edit text (.txt) files, but many users
find Notepad a simple tool for creating Web pages. It has been a quest for many
programmers to build Notepad using different programming languages. I have
built up a basic Notepad program using Java technology. This Notepad supports
basic text editing features such as cut, copy, paste, delete etc.
Objectives of the Project
The basic objective of this project is to provide its users an easy to use Notepad
application.
Requirements for this application are gathered from the various sites so as to have
the idea about the type and working. Books on different websites are referred.
Notepad is easy to use, volatile application which can be used for preparing files
of various formats, like web pages, programs of many languages etc.
Keeping in mind the popularity of the use of Notepad for preparing almost all
types of files, its need is justified.
Feasibility Study
o Technical Feasibility
The proposed application is technically feasible because the
hardware and software required to develop and implement this
application can be made available easily. It uses easy to navigate
user interface thus, this will reduce the length of the process required
to complete a request.
o Economical Feasibility
According to the economic point of view the system seems feasible
because after the one time cost of the hardware and the development
of the software, the running cost is minimal. The user just needs to
use the application as and when required.
o Operational Feasibility
The proposed application is very simple to operate. This is because
of the reason that a Notepad is very easy to learn and use, no special
training is needed to use it.
Use cases can be employed during several stages of software development, such as
planning system requirements, validating design, testing software, and creating an
outline for online help and user manuals.
USE CASE FOR THE APPLICATION:
<<include>>
Help
Flowchart
Symbols
A typical flowchart from older Computer Science textbooks may have the
following kinds of symbols:
Arrows
Showing what's called "flow of control" in computer science. An arrow
coming from one symbol and ending at another symbol represents that
control passes to the symbol the arrow points to.
Processing steps
Represented as rectangles. Examples: "Add 1 to X"; "replace identified
part"; "save changes" or similar.
Input/Output
Represented as a parallelogram. Examples: Get X from the user; display X.
Conditional or decision
Represented as a diamond (rhombus). These typically contain a Yes/No
question or True/False test. This symbol is unique in that it has two arrows
coming out of it, usually from the bottom point and right point, one
corresponding to Yes or True, and one corresponding to No or False. The
arrows should always be labeled. More than two arrows can be used, but
this is normally a clear indicator that a complex decision is being taken, in
which case it may need to be broken-down further, or replaced with the
"pre-defined process" symbol.
A number of other symbols that have less universal currency, such as:
START
READ
LINK
NO
YES
Is Link= Display editing
Edit options
NO
YES Perform
Is Link= Display formatting
options selected
Format operation
NO
Is Link= YES
Display help
Help
NO
End
System Requirement Specifications
The software required for the project is JVM (Java Virtual Machine).
SYS
TEM’S STUDY
General Description:
This application interacts with the user by the help of a graphical user interface
provided. The documentation is done using file handling utility provided in Java.
Environment description:
Inputs:
Input from the operator can be any of the commands related to file handling or
editing files.
Outputs:
Depending upon the operator command, the respective sub procedures are
triggered and further processing takes place. The result of the command shall be
displayed on the front end, which is the provided user interface in this case.
Functional division:
The most important part of the system is the designing part. The main parts of
designing are: Input design, Output design and File design.
Input design:
Every system depends upon some input for processing, and the accuracy of input
is the key to input designing.
Output design:
Every system generates output after processing the received inputs. The main
purpose of this application is to provide its users an easy to use text editor.
File design:
The most challenging phase in this system is designing the program files.
• Program files
Functional
Requirements:
GUI:
Graphical user interface has to be built so as to ease the operator. It shall take in
commands based on menu selections and send commands to the back end process.
The results are again displayed on the GUI.
Types of operators:
The operator/user for the application can be anyone who wishes to have a basic
and easy to use text editor.
Facilities available:
• File handling
• Edit options to make changes in the existing files
• Formatting option
• Help menu
System Design
1. A front end
Depending on the type of interface (Graphical), the front end handles the
display accordingly. This part will run on PC and provide the input output
capabilities.
2. A back end
Constraints:
Notepad.Java
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.util.Date;
import java.util.Calendar;
import java.util.GregorianCalendar;
import javax.swing.JOptionPane;
import javax.swing.text.*;
import java.awt.datatransfer.*;
import javax.swing.JDialog;
public Notepad()
{
f=new JFrame("Notepad");
p=new JPanel();
//INITIALIZING MENUS
mb=new JMenuBar();
mFile=new JMenu("File");
mEdit=new JMenu("Edit");
mFormat=new JMenu("Format");
mHelp=new JMenu("Help");
fNew=new JMenuItem("New");
fOpen=new JMenuItem("Open");
fSave=new JMenuItem("Save");
fExit=new JMenuItem("Exit");
eCut=new JMenuItem("Cut");
eCopy=new JMenuItem("Copy");
ePaste=new JMenuItem("Paste");
eDelete=new JMenuItem("Delete");
eTime=new JMenuItem("Date & Time");
eSelectAll=new JMenuItem("Select All");
mFile.add(fNew);
mFile.add(fOpen);
mFile.add(fSave);
mFile.addSeparator();
mFile.add(fExit);
mEdit.add(eCut);
mEdit.add(eCopy);
mEdit.add(ePaste);
mEdit.add(eDelete);
mEdit.add(eTime);
mEdit.add(eSelectAll);
mFormat.add(fWrap);
mFormat.add(fFont);
mHelp.add(hNotepad);
fNew.addActionListener(this);
fOpen.addActionListener(this);
fSave.addActionListener(this);
fExit.addActionListener(this);
//ADDING EVENT HANDLERS TO EDIT MENU ITEMS
eCut.addActionListener(this);
eCopy.addActionListener(this);
ePaste.addActionListener(this);
eDelete.addActionListener(this);
eTime.addActionListener(this);
eSelectAll.addActionListener(this);
fWrap.addActionListener(this);
fFont.addActionListener(this);
hNotepad.addActionListener(this);
mb.add(mFile);
mb.add(mEdit);
mb.add(mFormat);
mb.add(mHelp);
f.setJMenuBar(mb);
t=new JTextArea(10,10);
sc=new JScrollPane(t);
sc.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_A
LWAYS);
sc.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLB
AR_ALWAYS);
p.add(sc);
f.getContentPane().add(p);
f.setSize(100,100);
f.pack();
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
//MAIN METHOD
if(e.getSource()==fNew)
{
t.setText("");
}
else if(e.getSource()==fExit)
{
f.dispose();
}
else if(e.getSource()==fOpen)
{
//For dialog box use JFileChooser
FileReader(open.getSelectedFile().getPath()));
String s=b.readLine();
while(s!=null)
{
this.t.append(s+"\n");
s=b.readLine();
}
b.close();
}
catch(Exception e1)
{
System.out.println(e1.toString());
}
}
}
else if(e.getSource()==fSave)
{
JFileChooser save=new JFileChooser();
int option=save.showSaveDialog(this);
try
{
if(option==JFileChooser.APPROVE_OPTION)
{
File file=save.getSelectedFile();
if(file.exists())
{
int response=JOptionPane.showConfirmDialog(null,"File already exists. Do you
want to continue?","Overwrite
Confirmation",JOptionPane.OK_CANCEL_OPTION,JOptionPane.QUESTION_
MESSAGE);
if(response==JOptionPane.CANCEL_OPTION)
{
}
else
{
BufferedWriter b=new BufferedWriter(new
FileWriter(save.getSelectedFile().getPath()));
b.write(this.t.getText());
b.close();
}
}
else
{
b.write(this.t.getText());
b.close();
}
}
}
catch(Exception e1)
{
System.out.println(e1.toString());
}
}
else if(e.getSource()==eTime)
{
Date date=new Date();
GregorianCalendar calendar=new GregorianCalendar();
calendar.setTime(date);
String
strTime=calendar.get(Calendar.HOUR)+":"+calendar.get(Calendar.MINUTE)
+":"+calendar.get(Calendar.SECOND);
String
strDate=calendar.get((Calendar.MONTH)+1)+"/"+calendar.get(Calendar.DATE)
+"/"+calendar.get(Calendar.YEAR);
else if(e.getSource()==eCopy)
{
str=this.t.getSelectedText();
}
else if(e.getSource()==eCut)
{
str=this.t.getSelectedText();
int start=this.t.getSelectionStart();
int end=this.t.getSelectionEnd();
this.t.replaceRange("",start,end);
StringSelection ss = new
StringSelection(str);
}
else if(e.getSource()==ePaste)
{
int start=this.t.getSelectionStart();
int end=this.t.getSelectionEnd();
this.t.replaceRange(str,start,end);
}
else if(e.getSource()==eDelete)
{
int start=this.t.getSelectionStart();
int end=this.t.getSelectionEnd();
this.t.replaceRange("",start,end);
}
else if(e.getSource()==eSelectAll)
{
this.t.selectAll();
}
else if(e.getSource()==fFont)
{
JFontChooser fd = new JFontChooser(this,t.getFont());
fd.show();
if(fd.getReturnStatus() == fd.RET_OK)
{
t.setFont(fd.getFont());
}
fd.dispose();
}
else if(e.getSource()==fWrap)
{
t.setLineWrap(true);
sc.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLB
AR_NEVER);
}
else if(e.getSource()==hNotepad)
{
JOptionPane.showMessageDialog(this,"Created by ROHIT
AGGARWAL","Notepad",JOptionPane.INFORMATION_MESSAGE);
}
}
}
JFontChooser.java
Import java.awt.*;
public class JFontChooser extends javax.swing.JDialog {
public JFontChooser() {
super((javax.swing.JFrame)null);
this.font = new Font("Dialog",Font.PLAIN,12);
initComponents();
lblPreview.setFont(font);
}
setTitle("Select Font");
setModal(true);
setResizable(false);
addWindowListener(new java.awt.event.WindowAdapter() {
public void windowClosing(java.awt.event.WindowEvent evt) {
closeDialog(evt);
}
});
fontPanel.setLayout(new java.awt.GridBagLayout());
jLabel1.setText("Font");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(1, 1, 1, 1);
gridBagConstraints.weightx = 2.0;
fontPanel.add(jLabel1, gridBagConstraints);
jLabel2.setText("Style");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(1, 1, 1, 1);
fontPanel.add(jLabel2, gridBagConstraints);
jLabel3.setText("Size");
gridBagConstraints = new java.awt.GridBagConstraints();
gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
gridBagConstraints.insets = new java.awt.Insets(1, 1, 1, 1);
gridBagConstraints.weightx = 0.2;
fontPanel.add(jLabel3, gridBagConstraints);
lstFont.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELEC
TION);
lstFont.addListSelectionListener(new
javax.swing.event.ListSelectionListener() {
public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
lstFontValueChanged(evt);
}
});
jScrollPane1.setViewportView(lstFont);
lstStyle.setModel(new javax.swing.AbstractListModel() {
String[] strings = { "Plain", "Bold", "Italic", "Bold Italic" };
public int getSize() { return strings.length; }
public Object getElementAt(int i) { return strings[i]; }
});
lstStyle.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELEC
TION);
lstStyle.addListSelectionListener(new
javax.swing.event.ListSelectionListener() {
public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
lstStyleValueChanged(evt);
}
});
jScrollPane2.setViewportView(lstStyle);
lstSize.setModel(new javax.swing.AbstractListModel() {
String[] strings = { "8", "10", "11", "12", "14", "16", "20", "24", "28",
"36", "48", "72", "96" };
public int getSize() { return strings.length; }
public Object getElementAt(int i) { return strings[i]; }
});
lstSize.setSelectionMode(javax.swing.ListSelectionModel.SINGLE_SELEC
TION);
lstSize.addListSelectionListener(new
javax.swing.event.ListSelectionListener() {
public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
lstSizeValueChanged(evt);
}
});
jScrollPane3.setViewportView(lstSize);
mainPanel.add(fontPanel);
previewPanel.setLayout(new java.awt.BorderLayout());
previewPanel.setBorder(new javax.swing.border.TitledBorder(null,
"Preview", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION,
javax.swing.border.TitledBorder.DEFAULT_POSITION, new
java.awt.Font("Dialog", 0, 12)));
lblPreview.setFont(new java.awt.Font("Dialog", 0, 12));
lblPreview.setText("ABCDEFG abcdefg");
previewPanel.add(lblPreview, java.awt.BorderLayout.CENTER);
mainPanel.add(previewPanel);
getContentPane().add(mainPanel, java.awt.BorderLayout.CENTER);
buttonPanel.setLayout(new
java.awt.FlowLayout(java.awt.FlowLayout.RIGHT));
okButton.setText("OK");
okButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
okButtonActionPerformed(evt);
}
});
buttonPanel.add(okButton);
cancelButton.setText("Cancel");
cancelButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cancelButtonActionPerformed(evt);
}
});
buttonPanel.add(cancelButton);
getContentPane().add(buttonPanel, java.awt.BorderLayout.SOUTH);
pack();
java.awt.Dimension screenSize =
java.awt.Toolkit.getDefaultToolkit().getScreenSize();
setSize(new java.awt.Dimension(443, 429));
setLocation((screenSize.width-443)/2,(screenSize.height-429)/2);
}
• When user wishes to open a previously existing file, an open file dialog box
is shown, as is shown in the following snapshot
• When user needs to save his/her file, the user is shown a save file dialog
box to achieve this, as shown below
• The application also provides provision for document editing tasks, the
possible options are shown in the following snapshot
• The formatting option is also there
• If user wishes to set the font of the text to be typed in the document, he/she
can use the font menu item from format menu as shown in following
snapshot
• The help menu is used to show the information about the application as
follows
As can be seen from the snapshots, this application provides its users an
easy to use text editor, where the user can either open or save files and also
can use editing options.
S
oftware Testing
The software engineering process may be viewed as the spiral illustrated in Figure.
Initially, system engineering defines the role of software and leads to software
requirements analysis, where the information domain, function, behavior,
performance, constraints, and validation criteria for software are established.
Moving inward along the spiral, we come to design and finally to coding. To
develop computer software, we spiral inward along streamlines that decrease the
level of abstraction on each turn.
Software testing steps
Unit Testing
The module interface is tested to ensure that information properly flows into and
out of the program unit under test.
Unit Test
Integration Testing
Top-down Integration:
Then, the central and right hand control paths are built. Breadth-first integration
incorporates all components directly subordinate at each level, moving across the
structure horizontally. From the figure, components M2, M3, and M4 (a
replacement for stub S4) would be integrated first. The next control level, M5,
M6, and so on, follows.
Validation Testing
At the culmination of integration testing, software is completely assembled as a
package, interfacing errors have been uncovered and corrected, and a final series
of software tests—validation testing—may begin.
S
ystem Testing
Finally to rectify these errors we have made a test plan which works as
follows:
Test Plan
In our test plan we divided testing on different level so that testing can be
performed from basic unit testing to final acceptance testing.
Unit Testing
1. Test Units
We first try to find out or fix the units to be tested and we found that two or
more modules can be taken together and can be dealt as a single unit. For this we
keep our project in mind so that testing should be performed in accordance with
the requirements of the projects. As our project using developer as front-end tool
we made every form and each report (among various types of reports) as basic
units. For each unit, test cases have been made and their output verified. Then we
came to integration of modules for integration testing.
2. Features Tested
All the functional features specified in the requirements have been tested.
This way, we have done rigorous testing of software which ensures that the
software will be robust and reliable.
Furt
her Enhancement
Further enhancement of the application can contain options like file printing
option, page setup option, file compression and expansion options, which are not
included in this version of the application.
References
1. NIIT courseware
2. Head First Java, Second Edition by Kathy Sierra & Bert Bates
3. The Complete Reference, Second Edition by Thomas Powell & Fritz Schneider
4. http://www.w3schools.com