CrazyEngineers
  • vinci
    vinci

    MemberSep 30, 2011

    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
Howdy guest!
Dear guest, you must be logged-in to participate on CrazyEngineers. We would love to have you as a member of our community. Consider creating an account or login.
Replies
  • simplycoder

    MemberSep 30, 2011

    @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.
    <a href="https://en.wikipedia.org/wiki/Java_Media_Framework" target="_blank" rel="nofollow noopener noreferrer">Java Media Framework</a>
    Are you sure? This action cannot be undone.
    Cancel
  • Manish Goyal

    MemberOct 2, 2011

    this may help you
    #-Link-Snipped-#
    Are you sure? This action cannot be undone.
    Cancel
  • SheldonCooper

    MemberOct 5, 2011

    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)
    {}
    }
    }
    }
    Are you sure? This action cannot be undone.
    Cancel
Home Channels Search Login Register