-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFriendButton.java
More file actions
54 lines (43 loc) · 1.36 KB
/
FriendButton.java
File metadata and controls
54 lines (43 loc) · 1.36 KB
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
50
51
52
53
54
/* [ChatClient.java]
* A not-so-pretty implementation of a basic chat client
* @author Mangat
* @ version 1.0a
*/
import java.awt.*;
import javax.swing.*;
import java.util.ArrayList;
import java.awt.event.*;
import java.io.PrintWriter;
@SuppressWarnings("serial")
public class FriendButton extends JButton {
private boolean unread;
private int numNewMessages;
private String friend;
private ArrayList<FriendButton> friendListButtons;
public FriendButton(String friend, ArrayList<FriendButton> friendListButtons) {
this.friend = friend;
this.friendListButtons = friendListButtons;
this.unread = false;
setText(friend);
numNewMessages = 0;
}
public void setReadState(Boolean unread) {
if(unread == false) {
setBackground(new Color(245, 84, 66));
setText("You have " + numNewMessages + " new messages from " + friend);
} else {
setBackground(new JButton().getBackground());
setText(friend);
numNewMessages = 0;
}
}
public boolean getReadState() {
return this.unread;
}
public void setNumNewMessages(int numNewMessages) {
this.numNewMessages = numNewMessages;
}
public int getNumNewMessages() {
return this.numNewMessages;
}
}