From 48f09be2913eabb3dbbf6dee968160b62482fcfd Mon Sep 17 00:00:00 2001
From: mpriymak <mpriymak@gmail.com>
Date: Fri, 25 Oct 2019 19:00:58 +1100
Subject: [PATCH] Cleaned out the printstacktraces from the client and GUI
 classes.

---
 .../infinitymonkeys/GUI/PaintGUI.class        | Bin 7576 -> 7600 bytes
 src/GUI/DrawingArea.java                      |  12 +++++-----
 src/GUI/PaintGUI.java                         |   8 +++++--
 src/client/DrawingUpdate.java                 |  13 +++++++----
 src/client/EncryptionUpdate.java              |  21 +++++++++++-------
 5 files changed, 35 insertions(+), 19 deletions(-)

diff --git a/out/production/infinitymonkeys/GUI/PaintGUI.class b/out/production/infinitymonkeys/GUI/PaintGUI.class
index bdf80ef5f698d814a37a2f9388bbc28c31845266..daee65b2e541591bc7d7cc42b71c181213f8f428 100644
GIT binary patch
delta 173
zcmbPXy}^2exeRAI0}}%y0|SHRWCt0AP^~Qt5zN~dS~oH<FfcLfVqjp9VqjxnU|ht&
z!MK<~fN=?f1mjW$1;%9z8jQ;sb~7+A@IZ7k9A`Mez`(%BaF5{@10%yu1_lO%$tz_P
nEI}r-U@>_W0|(=31_8!33=)iM859`TF=#NZM>cu#H<?8M1TY{L

delta 149
zcmdmBJ;Qo~xeRAC0}}%y0|SHNWCs}q&y5TW3``8W7#JAD7+4t?7#A^cFfL{gU|hl=
z!MKz`fpHnbZUzPh9*7Qx;|wPl7#J8C?lIhAU}V_Iz`%eoZL5reF1l$e88{eMF$gfO
TW{_Z9!=S*p7TL7Pe6ouGT7Vc!

diff --git a/src/GUI/DrawingArea.java b/src/GUI/DrawingArea.java
index cd757c3..cc4d387 100644
--- a/src/GUI/DrawingArea.java
+++ b/src/GUI/DrawingArea.java
@@ -126,7 +126,8 @@ public class DrawingArea extends JPanel implements MouseMotionListener, MouseLis
         try {
             ImageIO.write(image, "PNG", file);
         } catch (IOException e) {
-            e.printStackTrace();
+            StartScreen.showErrorMessage("Error in saving PNG");
+            //e.printStackTrace();
         }
     }
 
@@ -137,7 +138,8 @@ public class DrawingArea extends JPanel implements MouseMotionListener, MouseLis
         try {
             ImageIO.write(imageJPG, "JPG", file);
         } catch (IOException e) {
-            e.printStackTrace();
+            StartScreen.showErrorMessage("Error in saving JPG");
+            //e.printStackTrace();
         }
     }
 
@@ -145,7 +147,8 @@ public class DrawingArea extends JPanel implements MouseMotionListener, MouseLis
         try {
             image = ImageIO.read(file);
         } catch (IOException e) {
-            e.printStackTrace();
+            StartScreen.showErrorMessage("Error in opening file");
+            //e.printStackTrace();
         }
         repaint();
     }
@@ -212,8 +215,7 @@ public class DrawingArea extends JPanel implements MouseMotionListener, MouseLis
                 g2.drawString(textString, startPoint.x, startPoint.y);
                 try {
                     client.getDrawingController().broadcastText(client.getUserName(), textString, g2.getFont(), shapeColor, startPoint);
-                } catch (RemoteException ex)
-                {
+                } catch (RemoteException ex) {
                     StartScreen.showErrorMessage("Connection with server lost");
                     System.exit(0);
                     //ex.printStackTrace();
diff --git a/src/GUI/PaintGUI.java b/src/GUI/PaintGUI.java
index 72d632a..7d06d8a 100644
--- a/src/GUI/PaintGUI.java
+++ b/src/GUI/PaintGUI.java
@@ -84,7 +84,8 @@ public class PaintGUI extends JPanel {
             textBtn = new JButton(new ImageIcon(textIcon));
             textBtn.addActionListener(actionListener);
         } catch (Exception e) {
-            e.printStackTrace();
+            StartScreen.showErrorMessage("Error setting up canvas buttons");
+            //e.printStackTrace();
         }
 
         strokeOptions = new JComboBox(strokes);
@@ -248,7 +249,8 @@ public class PaintGUI extends JPanel {
                         baos.close();
                     }
                     catch (IOException err) {
-                        err.printStackTrace();
+                        StartScreen.showErrorMessage("Error writing file");
+                        //err.printStackTrace();
                     }
 
                     try {
@@ -419,6 +421,7 @@ public class PaintGUI extends JPanel {
         openBtn.setEnabled(false);
         saveBtn.setEnabled(false);
         saveAsBtn.setEnabled(false);
+        clearBtn.setEnabled(false);
     }
 
     public void enableFileControl() {
@@ -426,6 +429,7 @@ public class PaintGUI extends JPanel {
         openBtn.setEnabled(true);
         saveBtn.setEnabled(true);
         saveAsBtn.setEnabled(true);
+        clearBtn.setEnabled(true);
     }
 
 }
\ No newline at end of file
diff --git a/src/client/DrawingUpdate.java b/src/client/DrawingUpdate.java
index bb92006..e7f4efc 100644
--- a/src/client/DrawingUpdate.java
+++ b/src/client/DrawingUpdate.java
@@ -1,5 +1,6 @@
 package client;
 
+import GUI.StartScreen;
 import remote.IDrawingUpdate;
 
 import javax.swing.*;
@@ -155,8 +156,10 @@ public class DrawingUpdate extends UnicastRemoteObject implements IDrawingUpdate
 
             // do whatever you wish with the image
         }
-        catch (IOException err) {
-            err.printStackTrace();
+        catch (IOException err)
+        {
+            StartScreen.showErrorMessage("Error in receiving image");
+            //err.printStackTrace();
         }
         return true;
     }
@@ -185,8 +188,10 @@ class removeClientTimer extends Thread {
                 elementIndex = temp.indexOf(fromClient);
                 temp.remove(elementIndex);
             }
-        } catch (InterruptedException e) {
-            e.printStackTrace();
+        } catch (InterruptedException e)
+        {
+            StartScreen.showErrorMessage("Interrupted Exception");
+            //e.printStackTrace();
         }
     }
 
diff --git a/src/client/EncryptionUpdate.java b/src/client/EncryptionUpdate.java
index 52d1fa5..33500cb 100644
--- a/src/client/EncryptionUpdate.java
+++ b/src/client/EncryptionUpdate.java
@@ -1,5 +1,6 @@
 package client;
 
+import GUI.StartScreen;
 import remote.IDrawingUpdate;
 import remote.IEncryptionUpdate;
 
@@ -35,15 +36,20 @@ public class EncryptionUpdate extends UnicastRemoteObject implements IEncryption
 
 
         } catch (NoSuchAlgorithmException e) {
-            e.printStackTrace();
+            StartScreen.showErrorMessage("Shared key error");
+            //e.printStackTrace();
         } catch (NoSuchProviderException e) {
-            e.printStackTrace();
+            StartScreen.showErrorMessage("Shared key error");
+            //e.printStackTrace();
         } catch (NoSuchPaddingException | InvalidKeyException e) {
-            e.printStackTrace();
+            StartScreen.showErrorMessage("Shared key error");
+            //e.printStackTrace();
         } catch (BadPaddingException e) {
-            e.printStackTrace();
+            StartScreen.showErrorMessage("Shared key error");
+            //e.printStackTrace();
         } catch (IllegalBlockSizeException e) {
-            e.printStackTrace();
+            StartScreen.showErrorMessage("Shared key error");
+            //e.printStackTrace();
         }
 
 
@@ -59,9 +65,8 @@ public class EncryptionUpdate extends UnicastRemoteObject implements IEncryption
 
         }
         catch (Exception e){
-            e.printStackTrace();
+            StartScreen.showErrorMessage("Encryption Update error");
+            //e.printStackTrace();
         }
-
     }
-
 }
-- 
GitLab