Beruflich Dokumente
Kultur Dokumente
-Title Page
Chat Client
Developed by Avick Saha
-Introduction
This is the GUI interface for a chat client terminal & this is a user friendly java
application. Through this window a client can interact with other people and type text. Even user
list is displayed for easy selection.
Bibliography
Internal Documentation::
-What is Name of the Project or Component..
Chat Client
-Who wrote this project..
Avick Saha
-where does the Component fit in the general System design..
This java application is the client side for the chat application. It requires server side to
interact.
-MODULE FUNCTIONALITY
There are five class involved in this project.
1) ChatClient
This is the main class for the project. It contains the rest of the classes.
2) SendHandler
This class is used to handle event when a client types and press enter, the text will be shifted
to the main text panel.
3) CloseHandler
Used to handle the event to close the main project window.
4) AboutHandler
5) AboutDialog
source code
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class ChatClient
{
private JTextArea output;
private JTextField input;
private JButton sendButton;
private JButton quitButton;
private JComboBox usernames;
private JScrollPane textPane;
private JDialog aboutDialog;
JFrame frame;
public ChatClient()
{
output = new JTextArea(10,50);
input = new JTextField(50);
sendButton =new JButton("Send");
quitButton = new JButton("Quit");
usernames = new JComboBox();
usernames.addItem("Jane Doe");
usernames.addItem("1337dud3");
usernames.addItem("Java Geek");
textPane = new
JScrollPane(output,ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED
,ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
}
public void launchFrame(){
JFrame frame = new JFrame("Chat Room");
frame.setLayout(new BorderLayout());
frame.add(input,BorderLayout.SOUTH);
JPanel p1 = new JPanel();
p1.setLayout(new GridLayout(3,1));
p1.add(sendButton);
p1.add(quitButton);
p1.add(usernames);
frame.add(p1,BorderLayout.CENTER);
sendButton.addActionListener(new SendHandler());
frame.addWindowListener(new CloseHandler());
quitButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
System.exit(0);
}
});
frame.add(textPane,BorderLayout.WEST);
JMenuBar mb = new JMenuBar();
JMenu file = new JMenu("File");
JMenuItem quitMenuItem = new JMenuItem("Quit");
quitMenuItem.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
System.exit(0);
}
});