Chat Application Write a GUI Java program to implement a client/server chat application using Java sockets and threads.

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Chat Application Write a GUI Java program to implement a client/server chat application using Java sockets and threads.

Post by answerhappygod »

Chat Application Write A Gui Java Program To Implement A Client Server Chat Application Using Java Sockets And Threads 1
Chat Application Write A Gui Java Program To Implement A Client Server Chat Application Using Java Sockets And Threads 1 (27.42 KiB) Viewed 34 times
by the below code i need put GUI inside it (java) :
import java.net.*;import java.util.*;import java.io.*;class ReceiverThread extends Thread{ Socket s; public ReceiverThread(Socket s2){ super(); this.s=s2; } public void run(){ Scanner sr; try { sr = new Scanner (s.getInputStream()); String str; do{ str=sr.nextLine(); System.out.println("Client "+str); }while(true); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }}class SenderThread extends Thread{ Socket s; public SenderThread(Socket s2){ super(); this.s=s2; } public void run(){ Scanner sc = new Scanner (System.in); try { PrintWriter pw = new PrintWriter(s.getOutputStream(),true); String st; do{ st=sc.nextLine(); pw.println("Server "+st); }while(true); } catch (IOException e) { e.printStackTrace(); } }}public class SERVER { public static void main(String[] args) throws UnknownHostException, IOException { ServerSocket ss = new ServerSocket(1534); Socket s= ss.accept(); SenderThread t = new SenderThread(s); ReceiverThread t1 = new ReceiverThread(s); t.start(); t1.start(); }}package ss;import java.net.*;import java.util.*;import java.io.*;class ReceiverThread extends Thread{ Socket s; public ReceiverThread(Socket s2){ super(); this.s=s2; } public void run(){ Scanner sr; try { sr = new Scanner (s.getInputStream()); String str; do{ str=sr.nextLine(); System.out.println("Server "+str); }while(true); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }}class SenderThread extends Thread{ Socket s; public SenderThread(Socket s2){ super(); this.s=s2; } public void run(){ Scanner sc = new Scanner (System.in); try { PrintWriter pw = new PrintWriter(s.getOutputStream(),true); String st; do{ st=sc.nextLine(); pw.println("Client "+st); }while(true); } catch (IOException e) { e.printStackTrace(); } }}public class Client { public static void main(String[] args) throws UnknownHostException, IOException { Socket s = new Socket(InetAddress.getLocalHost(),1534);SenderThread t = new SenderThread(s);ReceiverThread t1 = new ReceiverThread(s);t.start();t1.start(); }}
import java.net.*;
import java.util.*;
import java.io.*;
class ReceiverThread extends Thread{
Socket s;
public ReceiverThread(Socket s2){
super();
this.s=s2;
}
public void run(){
Scanner sr;
try {
sr = new Scanner (s.getInputStream());
String str;
do{
str=sr.nextLine();
System.out.println("Client "+str);
}while(true);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
class SenderThread extends Thread{
Socket s;
public SenderThread(Socket s2){
super();
this.s=s2;
}
public void run(){
Scanner sc = new Scanner (System.in);
try {
PrintWriter pw = new PrintWriter(s.getOutputStream(),true);
String st;
do{
st=sc.nextLine();
pw.println("Server "+st);
}while(true);
} catch (IOException e) {
e.printStackTrace();
}
}
}
public class SERVER {
public static void main(String[] args) throws UnknownHostException, IOException {
ServerSocket ss = new ServerSocket(1534);
Socket s= ss.accept();
SenderThread t = new SenderThread(s);
ReceiverThread t1 = new ReceiverThread(s);
t.start();
t1.start();
}
}
package ss;
import java.net.*;
import java.util.*;
import java.io.*;
class ReceiverThread extends Thread{
Socket s;
public ReceiverThread(Socket s2){
super();
this.s=s2;
}
public void run(){
Scanner sr;
try {
sr = new Scanner (s.getInputStream());
String str;
do{
str=sr.nextLine();
System.out.println("Server "+str);
}while(true);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
class SenderThread extends Thread{
Socket s;
public SenderThread(Socket s2){
super();
this.s=s2;
}
public void run(){
Scanner sc = new Scanner (System.in);
try {
PrintWriter pw = new PrintWriter(s.getOutputStream(),true);
String st;
do{
st=sc.nextLine();
pw.println("Client "+st);
}while(true);
} catch (IOException e) {
e.printStackTrace();
}
}
}
public class Client {
public static void main(String[] args) throws UnknownHostException, IOException {
Socket s = new Socket(InetAddress.getLocalHost(),1534);
SenderThread t = new SenderThread(s);
ReceiverThread t1 = new ReceiverThread(s);
t.start();t1.start();
}
}
Chat Application Write a GUI Java program to implement a client/server chat application using Java sockets and threads. Server Server Client Connected to localhost Send Project instructions
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply