chat client in java

I want to develop a simple chat client in java and doesnt know where to begin from .i just know threading concepts amnd core java only but have capability to build so. Any help is welcome here.I just want to the steps to build a chat client software in java with eclipse and netbeans

Replies

  • simplycoder
    simplycoder
    @vinci : You should have a good understanding of JMF(Java Media Framework). I believe that there were discussions on this on CE some time ago, just search for JMF on this board and hopefully you can find it.
    Go through this link as well.
    Java Media Framework
  • Manish Goyal
    Manish Goyal
    this may help you
    #-Link-Snipped-#
  • SheldonCooper
    SheldonCooper
    Study the code below.You will get pretty good idea.Modify it according to your needs.And similarly write server code for this code to work.

    package javaapplication1;
    import java.awt.*;
    import java.awt.event.*;
    import java.net.*;
    import java.io.*;
    public class Client extends Frame implements ActionListener,Runnable
    {
    Socket s;
    BufferedReader br;
    BufferedWriter bw;
    TextField text;
    Button button1,button2;
    List list;
    public static void main(String args[])
    {
    new Client("Client Application:");
    }
    public void run()
    {
    try
    {
    s.setSoTimeout(1);
    }
    catch(Exception e)
    {
    }
    while(true)
    {
    try
    {
    list.addItem(br.readLine());
    }
    catch(Exception h)
    {}

    }
    }

    public Client(String m)
    {
    super(m);
    setSize(200,300);
    setLocation(300,0);
    this.setLayout(new BorderLayout());
    button1=new Button("Send");
    button2=new Button("Exit");
    button1.addActionListener(this);
    button2.addActionListener(this);
    list=new List();
    text=new TextField();
    add(list,"Center");
    add(button1,"West");
    add(button2,"East");
    add(text,"South");
    setVisible(true);
    try
    {
    s=new Socket("192.168.0.141",100);
    br=new BufferedReader(new InputStreamReader(s.getInputStream()));
    bw=new BufferedWriter(new OutputStreamWriter(s.getOutputStream()));
    Thread th;
    th=new Thread(this);
    th.start();
    }
    catch(Exception e)
    {
    }
    }
    public void actionPerformed(ActionEvent e)
    {
    if(e.getSource().equals(button2))
    {
    System.exit(0);
    }
    else
    {
    try
    {
    bw.write(text.getText());
    bw.newLine();
    bw.flush();
    }
    catch(Exception m)
    {}
    }
    }
    }

You are reading an archived discussion.

Related Posts

From time to time many revolutionary technologies life span gets over. Telephone, Typewriter, Cassette Player, Walkman, Pager.... List is endless. What you think are the things that we use today...
Hi this is vamshi from warangal,Andhra Pradesh,INDIA.I recently entered in an unimaginable world i.e nthg but ENGINEERING.I need some engineer's as my friend's.I hope that many people in this network...
Guys every company have their rules regarding recruitment chances like if anyone appeared for infosys test then he/she can apply again after 9 months only. But i am confused here....
I knew that US people have days for all sorts of things. It seems but right that they have a day for mistakes: OCTOBER 1. There is no need for...
Toyota has unveiled a violin playing Robot. It can play violin although not so good. What is your reaction after listening to this? 😁 [video=youtube;EzjkBwZtxp4]https://www.youtube.com/watch?v=EzjkBwZtxp4[/video]