From 9786831400055fdc4e6ad56619bd52ba67624f94 Mon Sep 17 00:00:00 2001
From: Hai HoDac <hhodac@student.unimelb.edu.au>
Date: Fri, 25 Oct 2019 15:20:05 +1100
Subject: [PATCH] Fixed code

---
 src/GUI/DrawingArea.java      |  8 ++++----
 src/client/DrawingUpdate.java | 15 +++++++++++++++
 2 files changed, 19 insertions(+), 4 deletions(-)

diff --git a/src/GUI/DrawingArea.java b/src/GUI/DrawingArea.java
index 6282dfd..5c4b24d 100644
--- a/src/GUI/DrawingArea.java
+++ b/src/GUI/DrawingArea.java
@@ -292,9 +292,9 @@ public class DrawingArea extends JPanel implements MouseMotionListener, MouseLis
             if (currentMode == Mode.TEXT){
                 notifyUsingTimer();
             }
-            else {
-                drawingController.broadcastDrawingUserStopped(client.getUserName());
-            }
+//            else {
+//                drawingController.broadcastDrawingUserStopped(client.getUserName());
+//            }
 
         } catch (RemoteException ex) {
             ex.printStackTrace();
@@ -403,7 +403,7 @@ public class DrawingArea extends JPanel implements MouseMotionListener, MouseLis
         try {
             if (currentMode != Mode.TEXT){
                 drawingController.broadcastDraggingDrawing(client.getUserName(), drawing, currentMode.toString(), shapeColor, strokeSize);
-                drawingController.broadcastDrawingUser(client.getUserName());
+//                drawingController.broadcastDrawingUser(client.getUserName());
             }
 
         } catch (RemoteException ex) {
diff --git a/src/client/DrawingUpdate.java b/src/client/DrawingUpdate.java
index 60ea668..9f526a7 100644
--- a/src/client/DrawingUpdate.java
+++ b/src/client/DrawingUpdate.java
@@ -74,6 +74,12 @@ public class DrawingUpdate extends UnicastRemoteObject implements IDrawingUpdate
         g2.setColor(color);
         client.getApplicationMain().getPaintGUI().getDrawingArea().repaint();
 
+        DefaultListModel temp = client.getApplicationMain().getChatScreen().getAllUserModel();
+        int elementIndex = -1;
+        if(temp.contains(fromClient)){
+            elementIndex = temp.indexOf(fromClient);
+            temp.remove(elementIndex);
+        }
         return true;
     }
 
@@ -96,6 +102,15 @@ public class DrawingUpdate extends UnicastRemoteObject implements IDrawingUpdate
                 break;
         }
         client.getApplicationMain().getPaintGUI().getDrawingArea().repaint();
+
+        DefaultListModel temp = client.getApplicationMain().getChatScreen().getAllUserModel();
+        if(temp.contains(fromClient)){
+            System.out.println("Already in the list");
+        }
+        else {
+            temp.addElement(fromClient);
+        }
+
         return true;
     }
 
-- 
GitLab