-
Notifications
You must be signed in to change notification settings - Fork 0
/
ChatClientGUIimplement.java
49 lines (41 loc) · 1.31 KB
/
ChatClientGUIimplement.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
// Import RMI Libraries
import java.rmi.Remote;
import java.rmi.RemoteException;
import java.rmi.server.UnicastRemoteObject;
// Import Java Abstract Window Toolkit Libraries
import java.awt.List;
import java.awt.TextArea;
public class ChatClientGUIimplement extends UnicastRemoteObject implements ChatClient
{
// Each Client has a name,Client List,Chat Area
private String name;
private List clienList;
private TextArea chatArea;
// Constructor
public ChatClientGUIimplement(String name, List l, TextArea ar) throws RemoteException
{
this.name=name;
this.clienList = l;
this.chatArea = ar;
}
// Gets the Name of Client from GUI Frame
public String getName()
{
return this.name;
}
// The Client adds itself to the List of Clients present in the Chat Room
public void joined(String name)
{
this.clienList.add(name);
}
// The Client removes its name from the Client List once it logs out
public void left(String name)
{
this.clienList.remove(name);
}
// The Client Displays the message received from Server or other Clients
public void show_msg(String from, String msg)
{
this.chatArea.append("Message from: "+from+": "+msg+"\n");
}
}