Skip to content

Commit 060ccd3

Browse files
author
Nasim Bondar Sahebi
committed
editeing the chat entitiy and adding a Main method in ChatView class.
1 parent 581e260 commit 060ccd3

File tree

4 files changed

+26
-3
lines changed

4 files changed

+26
-3
lines changed

src/main/java/chatlinitation/ChatView.java

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,23 @@ public void actionPerformed(ActionEvent e) {
160160

161161
}
162162
}
163+
public static void main(String args[]) {
164+
EventQueue.invokeLater(new Runnable() {
165+
@Override
166+
public void run() {
167+
ChatView chat = new ChatView();
168+
chat.chatdisplay();
163169

170+
chat.addbutton.addActionListener(chat);
171+
//todo
172+
//after chat history is done next line code can run.
173+
// chat.send.addActionListener(chat);
174+
175+
176+
}
177+
});
178+
179+
}
164180

165181
}
166182

src/main/java/chatlinitation/ChatViewmodel.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
package chatlinitation;
2+
3+
import entities.PrivateChat;
4+
25
/**
36
* chatviewmodel connects our ChatView UI to our Entities.
47
* It provide data to the view, so that view can put that data on the screen.
@@ -24,15 +27,15 @@ public ChatViewmodel() {
2427

2528
// when we click the addbutton for username.our private chat should update it's Recipientusername.
2629
public void setRecipientUsername(String recipientUsername) {
27-
this.privatechat.setrecipientUsername(recipientUsername) ;
30+
this.privatechat.setRecipientUsername(recipientUsername) ;
2831
}
2932

3033

3134
//when type an input click send button , the input should set the txtmessge content
3235
//and privatechat should the txtmessage to conversation.
3336
public void setMessage(String content) {
3437
this.txtmessage.setMsgContent(content) ;
35-
privatechatchat.addtoconvHist(txtmessage);
38+
privatechat.addtoconvHist(txtmessage);
3639

3740
}
3841

src/main/java/entities/Chat.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,8 +47,9 @@ public ArrayList<Message> getConvHist(){
4747
* Add a message to the chat's conversation history when a message is sent or received
4848
* @param message Message that is sent or received
4949
*/
50-
public void sendRecieveMessage(Message message){
50+
public void addtoconvHist(Message message){
5151
this.convHist.add(message);
5252
}
5353

54+
5455
}

src/main/java/entities/PrivateChat.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,7 @@ public String getRecipientUsername(){
3737
return this.recipientUsername;
3838
}
3939

40+
public void setRecipientUsername(String recipientUsername) {
41+
this.recipientUsername= recipientUsername;
42+
}
4043
}

0 commit comments

Comments
 (0)