Skip to content

Commit

Permalink
add live users image to see the list of online users in that group an…
Browse files Browse the repository at this point in the history
…d tooltp text to logout, exit and live users images
  • Loading branch information
iamrohitsuthar committed Aug 9, 2019
1 parent 6a46b78 commit ef70fd2
Showing 1 changed file with 42 additions and 3 deletions.
45 changes: 42 additions & 3 deletions src/com/chatroom/ui/ChatActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public class ChatActivity {
private JPanel optionsButtonsHolder;
private JLabel jLabel_logout;
private JLabel jLabel_exit;
private JLabel jLabel_live;
private int tracker; //used for storing last maximum value of scroll bar
private boolean isSenderMsg;
private boolean isReadMode;
Expand All @@ -84,15 +85,22 @@ public ChatActivity(ClientModel clientModel) throws IOException {

BufferedImage logout = ImageIO.read(this.getClass().getResource("/logout.png"));
BufferedImage exit = ImageIO.read(this.getClass().getResource("/exit.png"));
BufferedImage liveUsers = ImageIO.read(this.getClass().getResource("/live.png"));


jLabel_logout = new JLabel(new ImageIcon(logout));
jLabel_logout.setPreferredSize(new Dimension(50,50));
jLabel_logout.setToolTipText("Logout");
jLabel_exit = new JLabel(new ImageIcon(exit));
jLabel_exit.setPreferredSize(new Dimension(50,50));
jLabel_exit.setToolTipText("Exit from group");
jLabel_live = new JLabel(new ImageIcon(liveUsers));
jLabel_live.setPreferredSize(new Dimension(50,50));
jLabel_live.setToolTipText("Current online users");

optionsButtonsHolder.add(jLabel_exit);
optionsButtonsHolder.add(jLabel_logout);

optionsButtonsHolder.add(jLabel_live);
optionsButtonsHolder.add(jLabel_logout);

rightBubbleConstraints = new GridBagConstraints(0, i, 1, 1, 1.0, 0,
GridBagConstraints.NORTHEAST, GridBagConstraints.NONE, new Insets(
Expand Down Expand Up @@ -182,6 +190,23 @@ public void mouseClicked(MouseEvent e) {
}
});

jLabel_live.addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) {
super.mouseClicked(e);
try {
request = new Request(Request.Type.MSG.ordinal(),clientModel.getClientID(),clientModel.getRoomId(),"sv_showusers");
ClientModel.objectOutputStream.writeObject(request);
ClientModel.objectOutputStream.flush();

} catch (IOException e1) {
e1.printStackTrace(new PrintWriter(Config.errors));
LogFileWriter.Log(Config.errors.toString());
}

}
});

jScrollPane.getVerticalScrollBar().addAdjustmentListener(new AdjustmentListener() {

//for updating scroll bar position on message received
Expand Down Expand Up @@ -363,6 +388,21 @@ public void run()
response = (Response) ClientModel.objectInputStream.readObject();
if(response.getId() == Response.Type.STATUS_MSG.ordinal() || response.getId() == Response.Type.LOGOUT.ordinal())
displayStatusMessages(response.getContents());
else if(response.getId() == Response.Type.GEN.ordinal()) {
String data = "List of Online Users \n";
int i = 1;
data += i + ". You \n";
String temp = response.getContents();
if(temp.length() != 0 && !temp.equals("")) {
String arrayOFNames[] = temp.split(",");
for (String string : arrayOFNames) {
i++;
data += i + ". " + string + "\n";
}
}
UIManager.put("OptionPane.okButtonText", "OK");
JOptionPane.showMessageDialog(null, data);
}
else {
String msg = response.getContents();
String name = msg.substring(0, msg.indexOf(" "));
Expand Down Expand Up @@ -414,4 +454,3 @@ public void run() {
}



0 comments on commit ef70fd2

Please sign in to comment.