0% found this document useful (0 votes)
74 views

Mniproject Report.

This document describes a mini project report for a stack based text editor created using Java. It was created by 4 students for their Artificial Intelligence and Machine Learning department. The text editor allows users to perform basic text editing functions like open, save, cut, copy and paste on text files. It uses Java Swing components for the graphical user interface and allows editing text in a platform independent way.

Uploaded by

add Romit
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
74 views

Mniproject Report.

This document describes a mini project report for a stack based text editor created using Java. It was created by 4 students for their Artificial Intelligence and Machine Learning department. The text editor allows users to perform basic text editing functions like open, save, cut, copy and paste on text files. It uses Java Swing components for the graphical user interface and allows editing text in a platform independent way.

Uploaded by

add Romit
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

1

MINIPROJECT
REPORT

SIES Graduate School of Technology,


Nerul, Navi Mumbai.

Department of Artificial Intelligence & Machine Learning

Department of Artificial Intelligence & Machine Learning


2

YEAR 2022-23.
MINI PROJECT REPORT ON

Submitted by
MEMBERS
Mr. Udayraj Narale [121A9033]
Mr. Nikhil Patel [121A9036]
Miss. Aditi Patwardhan [121A9042]
Miss. Nivedha Vellaipandi [121A9038]
GUIDED BY:
Prof. JYOTI CHAVHAN.

Principal
Dr. Atul Kemkar.
SIES GRADUATE SCHOOL OF TECHNOLOGY.

Department of Artificial Intelligence & Machine Learning


3

ACKNOWLEDGEMENT

The satisfaction and euphoria that accompany the successful completion of any task would be, but
impossible without the mention of the people who made it possible, whose constant guidance and
encouragement crowned our efforts with success.

We thank the management, Dr. Atul Kemkar, principal of SIES GRADUATE SCHOOL OF
TECHNOLOGY for providing necessary infrastructure and creating good environment. We also
record here the constant encouragement and facilities extended to us by Head of the Department of
Artificial Intelligence & Machine Learning Dr. Varsha Patil , Class Incharge, prof. Archana
Arudhkar and prof. Jyoti chavhan , of SIES GST.

We extend our sincere gratitude to them. We express our gratitude to prof. Jyoti chavhan , our
project guide for constantly monitoring the development of the project and setting up precise
deadlines. Their valuable suggestions were the motivating factors in completing the work.

We would also like to express our gratitude to SIES GST and to all our external guides at SIES GST
for their continuous guidance and motivation.

Finally a note of thanks to the teaching and non-teaching staff of Artificial Intelligence & Machine
Learning Department for their cooperation extended to us and our friends, who helped us directly or
indirectly in the course of the project work.

Mr. Udayraj Narale [121A9033]


Mr. Nikhil Patel [121A9036]
Miss. Aditi Patwardhan [121A9042]
Miss. Nivedha Vellaipandi [121A9038]

Department of Artificial Intelligence & Machine Learning


4

CERTIFICATE

This is certify that the Mini Project entitled “Stack Based Text Editor” is bonafide work carried by
Mr. Udayraj Narale , Mr. Nikhil Patel , Miss. Aditi Patwardhan , Miss. Nivedha Vellaipandi
from Department of Artificial Intelligence & Machine Learning (S.E) have satisfactorily completed .
The Mini Project “Stack Based Text Editor” is a fulfilment of term work for the subject Mini Project
in SIES GRADUATE SCHOOL OF TECHNOLOGY , Nerul during the academic year 2022-2023.

GUIDE. H.O.D.
PROF. JYOTI CHAVHAN. VARSHA PATIL.

Internal Examiner. External Examiner.

Place: SIES GST NERUL.


Date:

Department of Artificial Intelligence & Machine Learning


5

ABSTRACT

This application is a Stack Based Text Editor in JAVA. This text editor is developed in a JAVA platform is a
replica of the word editors we all are familiar with and which we use quite often on a daily basis. The only
difference being that, this editor has been created using JAVA for the front-end interface and it is platform
independent compile once and run everywhere with basic operations of the text editor cut ,copy ,paste ,file
,edit operations and any new features can be easily coded. After opening text editor use can enter data using
keyboard and edit existing document and open menu option to use save and save as options to save file. In
order to save file we should select directory or it will show default directory. To make editing simple, we have
provided a set of pop down menus in the interface, as well as support for shortcut keys to give commands .All
the features are developed using java swings.

Department of Artificial Intelligence & Machine Learning


6

DECLARATION

I hereby declare that the work entitled “Stack Based Text Editor” is record of my own work carried out by me
during academic year 2022-2023 under the supervision and guidance of prof. Jyoti Chavan , Department of
Artificial Intelligence & Machine Learning (S.E) , SIES Graduate School of Technology. The extend and
source of information are derived from the existing literature and have been indicated through the dissertation
at appropriate places . the matter embodied in this work is original and has not been submitted for the award
of any other degree and diploma , either in this or any other university.

Place : SIES GST NERUL.


Date :
( Signature of candidate )

Mr. Udayraj Narale [121A9033]

Mr. Nikhil Patel [121A9036]

Miss. Aditi Patwardhan [121A9042]

Miss. Nivedha Vellaipandi [121A9038]

Department of Artificial Intelligence & Machine Learning


7

CONTENTS
CHAPTER 1
INTRODUCTION

1.1 Information Consistency


1.2 Project Purpose
1.3 Project Features
1.4 Project Overview

CHAPTER 2
EDITORS

2.1 Definition
2.2 Types of Editors
2.3 Overview of Editing Process

CHAPTER 3
REQUIREMENT ANALYSIS

3.1 Overall Design


3.2 Product Perspective
3.3 Hardware Requirements
3.4 Software Requirements

CHAPTER 4
IMPLEMENTATION

4.1 Swing overview


4.2 Swing Controls
4.3 Swing Event Handling
4.4 Phase Development
4.5 Snapshots

CHAPTER 5
CONCLUSION AND FUTURE ENHANCEMENT

5.1 Conclusion
5.2 Future Enhancement

Department of Artificial Intelligence & Machine Learning


8

CHAPTER 1
INTRODUCTION

1.1 INFORMATION CONSISTENCY


An editor is general-purpose system software, which can be used to enter and/or modify text,
programs, graphics or data. An editor may be a line editor, screen editor, graphics editor or word
Processors. We will be discussing all these as we move on.

1.2 PROJECT PURPOSE


To develop a text editor in java that is platform independent that can be easily used by all the
users and if there are any changes required then a programmer can easily code and see the
changes and it most adaptable.

1.3 PROJECT FEATURES

BASIC FEATURES-
 File open – User can either open the files already existing n the system or open a new
blank file.
 Files save - one can save the file in any desired format like-.txt, .doc, .java etc. The file is
stored in the location specified by the user.
 Save As- one can save the file in any desired format like-.txt, .doc, .java etc. The file is
stored in any other location specified by the user.
 Cut-Copy-Paste – This editor also lets the user cut-copy-paste the edited text.

ADDITIONAL FEATURES-
 Font – This feature extends the user to change the font style of the edited text.
 Replace-It replaces the specified text.
 Font color- dynamic change in font color during typing as per users requirement.
 Scroll pane- users are not restricted for contents.
 Font size- dynamic change in font size while typing as per users requirement.

Department of Artificial Intelligence & Machine Learning


9

1.4 PROJECT OVERVIEW

 Project Name : Stack Based Text Editor .

 Project Type : Development Project .

 Front End : Java swings, AWT .

 Tools : IntelliJ IDEA .

 Operating system : Platfom Independent .

 Coding Language : Java .

This project “Text Editor” is software which can edit plain text. It is made using Java Swings and
AWT. In this project all the frames are designed in Swing. Today most programmers use Swing.
Swing is a set of classes that provides more powerful and flexible GUI components than does the
AWT. Swing provides the look and feel of the modern Java GUI.

Swing did not exist in the early days of Java. Rather, it was a response to deficiencies present in
Java’s original GUI subsystem: the Abstract Window Toolkit. The AWT defines a basic set of
controls, windows, and dialog boxes that support a usable, but limited graphical interface.

Department of Artificial Intelligence & Machine Learning


10

CHAPTER 2
EDITORS
2.1 DEFINITION
An editor is general-purpose system software, which can be used to enter and/or modify text,
programs, graphics or data. An editor may be a line editor, screen editor, graphics editor or word
Processors. We will be discussing all these as we move on.

2.2 TYPES OF EDITORS


Editors are broadly classified as
1. Line Editors
2. Screen Editors
3. Graphic Editors

2.3 OVERVIEW OF EDITING PROCESS


An interactive editor is a software program that allows a user to create and revise a target document.
The term document includes objects such as computer programs, text equations, tables, diagrams,
line art and photographs –anything we find on a hard copy. The text editor should be considered the
primary interface to the computers for all types of “knowledge workers” as they compose, organize,
study & manipulate computer based information. The primary elements being edited in a text editor
are character strings of the target text.

The interactive editing process is accomplished with the following tasks: The part of the target
document that needs to be manipulated is viewed. The document is first displayed in the required
format.

Using the necessary designed tools, the document is modified. The view is updated appropriately and
saved in this above process, the selection of the part of the document to be viewed and edited
involves first traveling through the document to locate the area of interest. Filtering controls the
process of what is to be viewed & manipulated. Filtering extracts the relevant subset of the target
document at the point of interest, such as the next screen of the text or the next statement.

In the actual editing phase, the target document is created or altered with a set of operations such as
insert, delete, move, copy. The editing functions are often specialized to operate on elements
meaningful to the type of editor. For example, a manuscript- oriented editor might operate on
elements such as single characters, words, lines, sentences, and paragraphs; a program-oriented
editor might operate on elements such as identifiers, keywords, and statements.

In a simple scenario, the, the user might travel to the end of the document. A screenful of text would
be filtered, this segment would be formatted, and the view would be displayed on an output device.
The user could then, for example, delete the first three words of this view.

Department of Artificial Intelligence & Machine Learning


11

CHAPTER 3
REQUIREMENT ANALYSIS

3.1 OVERALL DESCRIPTION


Java language is selected for designing this project. Several inbuilt functions and templates present
in Java language are used for making the coding easier.

3.2 PRODUCT PERSPECTIVE


The product is a full screen text editor with the capacity to edit existing files and create new ones. To
make editing simple, we have provided a set of pop down menus in the interface, as well as support
for shortcut keys to give commands.

3.3 HARDWARE REQUIREMENTS


 System : Pentium Dual Core.

 Hard Disk : 120 GB.

 Monitor : 15’’ LED

 Input Devices : Keyboard, Mouse

 Ram : 1GB.

3.4 SOFTWARE REQUIREMENTS:


 Operating system : Windows 10.

 Coding Language : JAVA.

 Tool : Intellij IDEA

INTELLIJ IDEA-
IntelliJ IDEA is an integrated development environment (IDE) written in Java for developing computer
software written in Java, Kotlin, Groovy, and other JVM-based languages. It is developed
by JetBrains (formerly known as IntelliJ) and is available as an Apache 2 Licensed community
edition,[2] and in a proprietary commercial edition. Both can be used for commercial development.

The first version of IntelliJ IDEA was released in January 2001 and was one of the first available Java IDEs
with advanced code navigation and code refactoring capabilities integrated.

In 2009, JetBrains released the source code for IntelliJ IDEA under the open-source Apache
License 2.0. JetBrains also began distributing a limited version of IntelliJ IDEA consisting of open-source
features under the moniker Community Edition. The commercial Ultimate Edition provides additional
features and remains available for a free.

Department of Artificial Intelligence & Machine Learning


12

In a 2010 InfoWorld report, IntelliJ received the highest test center score out of the four top Java
programming tools: Eclipse, IntelliJ IDEA, NetBeans and JDeveloper.

In December 2014, Google announced version 1.0 of Android Studio, an open-source IDE for Android apps,
based on the open source community edition. Other development environments based on IntelliJ's
framework include AppCode, CLion, DataGrip, GoLand, PhpStorm, PyCharm, Rider, RubyMine,
WebStorm, and MPS.

Supported languages
The Community and Ultimate editions differ in their support for various programming languages as shown
in the following

Supported in both Community and Ultimate Edition:

 CSS, Sass, SCSS, Less, Stylus


 Groovy
 HTML, XML, JSON, YAML
 Java
 Kotlin
 Markdown
 XSL, XPATH

Department of Artificial Intelligence & Machine Learning


13

CHAPTER 4
IMPLEMENTATION

4.1 SWING ─ OVERVIEW


Swing API is a set of extensible GUI Components to ease the developer's life to create JAVA based Front
End/GUI Applications. It is build on top of AWT API and acts as a replacement of AWT API, since it has
almost every control corresponding to AWT controls. Swing component follows a Model-View-Controller
architecture to fulfill the following criterias .

 A single API is to be sufficient to support multiple look and feel.


 API is to be model driven so that the highest level API is not required to have data.
 API is to use the Java Bean model so that Builder Tools and IDE can provide better services to
the developers for use.

4.2 SWING ─ CONTROLS


Every user interface considers the following three main aspects:
 UI Elements: These are the core visual elements the user eventually sees and interacts with.
GWT provides a huge list of widely used and common elements varying from basic to
complex, which we will cover in this tutorial.
 Layouts: They define how UI elements should be organized on the screen and provide a final
look and feel to the GUI (Graphical User Interface). This part will be covered in the Layout
chapter.
 Behavior: These are the events which occur when the user interacts with UI elements. This
part will be covered in the Event Handling chapter.

4.3 SWING -EVENT HANDLING

4.3.1 WHAT IS AN EVENT

Change in the state of an object is known as Event, i.e., event describes the change in the state of the source.
Events are generated as a result of user interaction with the graphical user interface components. For
example, clicking on a button, moving the mouse, entering a character through keyboard, selecting an item
from the list, and scrolling the page are the activities that causes an event to occur.

4.3.2 TYPES OF EVENT

The events can be broadly classified into two categories:

 Foreground Events - These events require direct interaction of the user. They are generated as
consequences of a person interacting with the graphical components in the Graphical User Interface.
For example, clicking on a button, moving the mouse, entering a character through keyboard,
selecting an item from list, scrolling the page, etc.

 Background Events – These events require the interaction of the end user. Operating system
interrupts, hardware or software failure, timer expiration, and operation completion are some
examples of background events.

Department of Artificial Intelligence & Machine Learning


14

4.3.3 WHAT IS EVENT HANDLING

Event Handling is the mechanism that controls the event and decides what should happen if an event occurs.
This mechanism has a code which is known as an event handler, that is executed when an event occurs. Java
uses the Delegation Event Model to handle the events. This model defines the standard mechanism to
generate and handle the events. The Delegation Event Model has the following key participants.

 Source - The source is an object on which the event occurs. Source is responsible for providing
information of the occurred event to it's handler. Java provide us with classes for the source object.

 Listener - It is also known as event handler. The listener is responsible for generating a response to
an event. From the point of view of Java implementation, the listener is also an object. The listener
waits till it receives an event. Once the event is received, the listener processes the event and then
returns. The benefit of this approach is that the user interface logic is completely separated from the
logic that generates the event. The user interface element is able to delegate the processing of an
event to a separate piece of code. In this model, the listener needs to be registered with the source
object so that the listener can receive the event notification. This is an efficient way of handling the
event because the event notifications are sent only to those listeners who want to receive them.

4.3.4 SWING ─ MENU CLASS

As we know that every top-level window has a menu bar associated with it. This menu bar consists of
various menu choices available to the end user. Further, each choice contains a list of options, which is
called drop-down menus. Menu and Menu Item controls are subclass of Menu Component class.

4.4 Phases of Development


This text editor supports many editing functions to the user. A user can edit a given text file. The different
editing features are Open file, Save file, Delete file, cut copy and paste, delete line/word, insert line/word.
The project is divided into three phases.

• Developing the graphical user interface.


• Writing the code for different functionality options.
• Code for user key functions.

Phase 1: Developing the background window and menu bar: The very first step in the development of the
editor is to construct the background window. Then the background color is set For each menu options
different sub windows are created and appropriate strings of different names are added into those sub
windows. Key Binding in each sub windows Each of the options in each of the menus are bound with or
associated with keys on the keyboard which are shortcuts for the user to access these options. The other way
to access them is using the movement of the cursor to navigate through them on the screen and even by
moving left and right through menus.

Phase 2: Coding functionality options In this phase we have used several inbuilt functions in the for buffers
within the editors. The various functions connect the back and front ends of the program and make it
interactive as well as efficient. Simple logic is used to code the same, for example the removal and insertion
of nodes in the list work to cut or paste text.

Department of Artificial Intelligence & Machine Learning


15

Phase 3: Coding for user key functions This phase maps each of the keys used by the user to a function
within the editor. The minimum movement of the user is using arrow-keys which is the first step after
enabling the keypad. After this, since ALT is used in the terminal to access various menus, we have used
CTRL with the first letter of each option to access menu-bars within the editor.

4.4.1 Code

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.*;
import javax.swing.*;
import javax.swing.event.ChangeEvent;
import javax.swing.event.ChangeListener;
import javax.swing.plaf.metal.MetalLookAndFeel;
import javax.swing.plaf.metal.OceanTheme;

public class TextEditor extends JFrame implements ActionListener {

JTextArea textArea;
JScrollPane ScrollPane;
JLabel FontLabel;
JSpinner fontSizeSizeSpinner;
JButton fontColorButton;
TextEditor(){

try {
UIManager.setLookAndFeel("javax.swing.plaf.metal.MetalLookAndFeel");
MetalLookAndFeel.setCurrentTheme(new OceanTheme());
setLocationRelativeTo(null);
}
catch (Exception e) {
}
textArea = new JTextArea();
JMenuBar mb = new JMenuBar();
JMenu m1 = new JMenu("File");
JMenuItem mi1 = new JMenuItem("New");
JMenuItem mi2 = new JMenuItem("Open");
JMenuItem mi3 = new JMenuItem("Save");
JMenuItem mi9 = new JMenuItem("Print");
mi1.addActionListener(this);
mi2.addActionListener(this);
mi3.addActionListener(this);
mi9.addActionListener(this);

m1.add(mi1);
m1.add(mi2);
m1.add(mi3);
m1.add(mi9);
JMenu m2 = new JMenu("Edit");
JMenuItem mi4 = new JMenuItem("cut");
JMenuItem mi5 = new JMenuItem("copy");
JMenuItem mi6 = new JMenuItem("paste");
mi4.addActionListener(this);

Department of Artificial Intelligence & Machine Learning


16

mi5.addActionListener(this);
mi6.addActionListener(this);

m2.add(mi4);
m2.add(mi5);
m2.add(mi6);

JMenuItem mc = new JMenuItem("close");

mc.addActionListener(this);

mb.add(m1);
mb.add(m2);
mb.add(mc);

this.setJMenuBar(mb);
this.add(textArea);
this.setSize(800, 500);
this.show();

this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setTitle("! Stack Based Text Editor !");
this.setSize(800,500);
this.setLayout(new FlowLayout());
this.setLocationRelativeTo(null);

textArea = new JTextArea();

textArea.setLineWrap(true);
textArea.setWrapStyleWord(true);
textArea.setFont(new Font("Arial",Font.PLAIN,20));

ScrollPane = new JScrollPane(textArea);


ScrollPane.setPreferredSize(new Dimension(780,480));

ScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);

FontLabel = new JLabel("Font: ");

fontSizeSizeSpinner = new JSpinner();


fontSizeSizeSpinner.setPreferredSize(new Dimension(50,25));
fontSizeSizeSpinner.setValue(20);
fontSizeSizeSpinner.addChangeListener(new ChangeListener() {
@Override
public void stateChanged(ChangeEvent e) {
textArea.setFont(new Font(textArea.getFont().getFamily(),Font.PLAIN, (Integer)
fontSizeSizeSpinner.getValue()));

}
});
fontColorButton = new JButton("color");
fontColorButton.addActionListener(this);
this.add(FontLabel);
this.add(fontSizeSizeSpinner);

Department of Artificial Intelligence & Machine Learning


17

this.add(fontColorButton);
this.add(ScrollPane);
this.setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) {

if (e.getSource() == fontColorButton) {
JColorChooser colorChooser = new JColorChooser();

Color color = colorChooser.showDialog(null, "Choose a color", Color.black);


textArea.setForeground(color);

String s = e.getActionCommand();

if (s.equals("cut")) {
textArea.cut();
} else if (s.equals("copy")) {
textArea.copy();
} else if (s.equals("paste")) {
textArea.paste();
} else if (s.equals("Save")) {
JFileChooser j = new JFileChooser("f:");
int r = j.showSaveDialog(null);

if (r == JFileChooser.APPROVE_OPTION) {
File fi = new File(j.getSelectedFile().getAbsolutePath());

try {
FileWriter wr = new FileWriter(fi, false);
BufferedWriter w = new BufferedWriter(wr);

w.write(textArea.getText());

w.flush();
w.close();
} catch (Exception evt) {
JOptionPane.showMessageDialog(this, evt.getMessage());
}
} else
JOptionPane.showMessageDialog(this, "the user cancelled the operation");
} else if (s.equals("Print")) {
try {
textArea.print();
} catch (Exception evt) {
JOptionPane.showMessageDialog(this, evt.getMessage());
}
} else if (s.equals("Open")) {
JFileChooser j = new JFileChooser("f:");
int r = j.showOpenDialog(null);

Department of Artificial Intelligence & Machine Learning


18

if (r == JFileChooser.APPROVE_OPTION) {
File fi = new File(j.getSelectedFile().getAbsolutePath());

try {
String s1 = "", sl = "";
FileReader fr = new FileReader(fi);
BufferedReader br = new BufferedReader(fr);
sl = br.readLine();
while ((s1 = br.readLine()) != null) {
sl = sl + "\n" + s1;
}
textArea.setText(sl);
} catch (Exception evt) {
JOptionPane.showMessageDialog(this, evt.getMessage());
}
} else
JOptionPane.showMessageDialog(this, "the user cancelled the operation");
} else if (s.equals("New")) {
textArea.setText("");
} else if (s.equals("close")) {
this.setVisible(false);
}
}
}
public class Main {
public static void main(String[] args) {
new TextEditor();
}
}

Department of Artificial Intelligence & Machine Learning


19

4.5 Snapshot

4.5.1 Main Window

4.5.2 File Menu.

Department of Artificial Intelligence & Machine Learning


20

4.3.3 Edit Menu.

4.5.4 Font & Text color.

Department of Artificial Intelligence & Machine Learning


21

4.5.3 Save

Department of Artificial Intelligence & Machine Learning


22

CHAPTER 5
CONCLUSION AND FUTURE ENHANCEMENT
5.1 CONCLUSION
This project that we undertook was truly a very rewarding experience for us in more than one way. It has
given a big thrust to our technical knowledge as prospective Software professional. It has also helped us
enhance our skills on the personal front. The project took equal contributions from all members. We could
able to apply academic knowledge of stack data structure and object oriented programming language i.e Java
for problem solving. By adding more GUI functions or developing a user friendly website using this logic,
prove to be more beneficial for the society. we feel extremely satisfied by the fact that we have managed to
develop the project. We think we have exploited the opportunity that came our way to the fullest extent by
increasing our technical know-how and also gaining the valuable work experience apart from studying the
other subjects in our curriculum.

5.2 FUTURE ENHANCEMENT


 Help page that connects to the Internet.

 Automatic dictionary.

 To insert images.

 To have templates.

Department of Artificial Intelligence & Machine Learning

You might also like