Chatting Application Full File PDF
Chatting Application Full File PDF
Chatting Application Full File PDF
2021-202
2
A MINI-PROJECT
REPORT ON
“CHATTING APPLICATION ”
Submitted by
Certified that the mini-project work entitled “CHATTING APPLICATION” is a bona fide work carried out by
There port has been approved as it satisfies the academic requirements in respect of mini-project work prescribed
for the course.
……………….……………..
Mr. PRAVEEN GUPTA
Mini-Project Coordinator
…….……………...………………
Dr. MUNISH KHANNA
Head of the Department
ABSTRACT
We are thankful to Dr. Munish Khanna (Head of the Department, CSE) and all
other faculty member for their kind support in carrying us out this work in the
college successfully.
We also express our gratitude and thanks to our staff tutors and all other
faculty members of the department of Computer Science and Engineering,
Hindustan College of Engineering and Technology, for their quick help and
expert opinions for completing this project.
ABSTRACT 1
ACKNOWLEDGEMENT 2
1. INTRODUCTION 4
OBJECTIVE 5
REQUIREMENTS 6
2. OPERATIONAL CONCEPTS 7
3. PROJECT SCOPE 8
SERVER 8
CLIENT 13
4. FUTURE WORK 18
5. CONCLUSION 19
6. REFERENCES… 20
INTRODUCTION
The aim of this project is to express how we can implement a simple chat application between a
server and a client? The application is a desktop based application and is implemented using
Swing and awt. The project is developed in Java SE language executed on a single stand-alone
java across a network using loop back address concept.
Server
Client
Server
The server module of the application waits for the client to connect to it. Then if connection is
granted a client interacts communicates and connects to the server, it can mutually
communicate with the server. The duty of the server is to let clients exchange the messages.
Client
The client module is the one that utilizer sends requests to the server. Utilizer utilizes the
client as the means to connect to the server. Once he establishes the connection, he can
communicate to the connected server.
REQUIREMENTS
The user interface required to be developed for the system should be user
friendly and attractive.
There are two sets of Java APIs for graphics programming:
Software Interfaces
Programming Language: JAVA
&
SOCKET PROGRAMMING
When the run button is clicked then the chat form is initialized with a
connection
● Contains a rich textbox which send messages from one user to another
● Contains a textbox for messages to be written that is sent across the network.
.∙ When the sent button is clicked, in the background, the text in the textbox is
encoded
● and sent as a packet over the network to the client machine. Here this
message is decoded and is shown in the rich textbox.
Project Scope
This project can be mainly divided into two modules:
1. Server
2. Client
This project is mainly depended on client/server model. The client requests the
server and server responses by granting the clients request. The proposed system
should provide both of the above features along with the followed ones:
Server
A server is a computer program that provides services to other computer
programs (and their users) in the same or other computers. The computer that a
server program runs in is also frequently referred to as a server. That machine
may be a dedicated server or used for other purposes as well. Example Server,
Database, Dedicated, Fileserver, Proxy Server, Web Server. The server is
always waiting for client’s requests. The client come and goes down but the
server remains the same.
Server Program
});
ImageIcon i4 = new
ImageIcon(ClassLoader.getSystemResource("com/company/icons/server1.png"));
Image i5 = i4.getImage().getScaledInstance(60, 60, Image.SCALE_DEFAULT);
ImageIcon i6 = new ImageIcon(i5);
JLabel l2 = new JLabel(i6);
l2.setBounds(40, 5, 60, 60);
p1.add(l2);
ImageIcon i7 = new
ImageIcon(ClassLoader.getSystemResource("com/company/icons/video.png"));
Image i8 = i7.getImage().getScaledInstance(30, 30, Image.SCALE_DEFAULT);
ImageIcon i9 = new ImageIcon(i8);
JLabel l5 = new JLabel(i9);
l5.setBounds(290, 20, 30, 30);
p1.add(l5);
t.setInitialDelay(2000);
a1 = new JPanel();
a1.setBounds(5, 75, 440, 570);
a1.setFont(new Font("SAN_SERIF", Font.PLAIN, 16));
f1.add(a1);
t1 = new JTextField();
t1.setBounds(5, 655, 310, 40);
t1.setFont(new Font("SAN_SERIF", Font.PLAIN, 16));
f1.add(t1);
t1.addKeyListener(new KeyAdapter(){
public void keyPressed(KeyEvent ke){
l4.setText("typing...");
t.stop();
typing = true;
}
if(!t.isRunning()){
t.start();
}
}
});
b1 = new JButton("Send");
b1.setBounds(320, 655, 123, 40);
b1.setBackground(new Color(7, 94, 84));
b1.setForeground(Color.WHITE);
b1.setFont(new Font("SAN_SERIF", Font.PLAIN, 16));
b1.addActionListener(this);
f1.add(b1);
f1.getContentPane().setBackground(Color.WHITE);
f1.setLayout(null);
f1.setSize(450, 700);
f1.setLocation(250, 20);
f1.setUndecorated(true);
f1.setVisible(true);
JPanel p2 = formatLabel(out);
a1.setLayout(new BorderLayout());
a1.add(vertical, BorderLayout.PAGE_START);
//a1.add(p2);
dout.writeUTF(out);
t1.setText("");
}catch(Exception e){
System.out.println(e);
}
}
On the client site the client knows the hostname of the machine on which the
server is running and the port number on which the server is listening.
To make a connection request, the client tries to rendezvous with the server on the
server's machine and port. The client also needs to identify itself to the server so it
binds to a local port number that it will use during this connection. This is usually
assigned by the system.
Client Program
package com.company;
import javax.swing.*;
import javax.swing.border.*;
import java.awt.*; import
java.awt.event.*; import
java.net.*; import
java.io.*;
import java.util.Calendar;
import java.text.SimpleDateFormat;
import javax.swing.*;
JPanel p1;
JTextField t1;
JButton b1; static
JPanel a1;
static JFrame f1 = new JFrame();
static Socket s;
static DataInputStream din;
static DataOutputStream dout;
Boolean typing;
client() {
f1.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
p1 = new JPanel();
p1.setLayout(null);
p1.setBackground(new Color(7, 94, 84));
p1.setBounds(0, 0, 450, 70);
f1.add(p1);
ImageIcon i1 = new
ImageIcon(ClassLoader.getSystemResource("com/company/icons/3.png"));
Image i2 = i1.getImage().getScaledInstance(30, 30, Image.SCALE_DEFAULT);
ImageIcon i3 = new ImageIcon(i2);
JLabel l1 = new JLabel(i3);
l1.setBounds(5, 17, 30, 30);
p1.add(l1);
l1.addMouseListener(new MouseAdapter() {
public void mouseClicked(MouseEvent ae) {
System.exit(0);
}
});
ImageIcon i4 = new
ImageIcon(ClassLoader.getSystemResource("com/company/icons/2.png"));
Image i5 = i4.getImage().getScaledInstance(60, 60, Image.SCALE_DEFAULT);
ImageIcon i6 = new ImageIcon(i5);
JLabel l2 = new JLabel(i6);
l2.setBounds(40, 5, 60, 60);
p1.add(l2);
ImageIcon i7 = new
ImageIcon(ClassLoader.getSystemResource("com/company/icons/video.png"));
Image i8 = i7.getImage().getScaledInstance(30, 30, Image.SCALE_DEFAULT);
ImageIcon i9 = new ImageIcon(i8);
JLabel l5 = new JLabel(i9);
l5.setBounds(290, 20, 30, 30);
p1.add(l5);
t.setInitialDelay(2000);
a1 = new JPanel();
a1.setBounds(5, 75, 440, 570);
a1.setFont(new Font("SAN_SERIF", Font.PLAIN, 16));
f1.add(a1);
t1 = new JTextField();
t1.setBounds(5, 655, 310, 40);
t1.setFont(new Font("SAN_SERIF", Font.PLAIN, 16));
f1.add(t1);
t1.addKeyListener(new KeyAdapter() {
public void keyPressed(KeyEvent ke) {
l4.setText("typing...");
t.stop();
typing = true;
}
b1 = new JButton("Send");
b1.setBounds(320, 655, 123, 40);
b1.setBackground(new Color(7, 94, 84));
b1.setForeground(Color.WHITE);
b1.setFont(new Font("SAN_SERIF", Font.PLAIN, 16));
b1.addActionListener(this);
f1.add(b1);
f1.getContentPane().setBackground(Color.WHITE);
f1.setLayout(null);
f1.setSize(450, 700);
f1.setLocation(900, 20);
f1.setUndecorated(true);
f1.setVisible(true);
try {
String out = t1.getText();
JPanel p2 = formatLabel(out);
a1.setLayout(new BorderLayout());
a1.add(vertical, BorderLayout.PAGE_START);
//a1.add(p2);
dout.writeUTF(out);
t1.setText("");
} catch (Exception e) {
System.out.println(e);
}
}
p3.add(l1);
p3.add(l2);
return p3;
}
THE CLIENT SCREEN
THE CLIENT SERVER SCREEN
Future work
There is always a room for improvements in any software package, however
good and efficient it may be done. But the most important thing should be
flexible to accept further modification. Right now we are just dealing with text
communication. In future this software may be extended to include features such
as:
Files transfer: this will enable the user to send files of different formats to others
via the chat∙ application.
Voice chat: this will enhance the application to a higher level where
communication will be possible via voice calling as in telephone.
Video chat: This will further enhance the feature of calling into video
communication.
Conclusion
Websites:
● https://www.w3schools.com/
● https://www.codewithharry.com/
● https://hcst.edu.in/
● https://erp.aktu.ac.in/
YouTube Channels:
● Apna College
● Code for Interview
● Gate Smashers
● Code with Harry
● PepCoding