diff --git a/src/GUI/icon/circle.png b/resources/circle.png similarity index 100% rename from src/GUI/icon/circle.png rename to resources/circle.png diff --git a/src/GUI/icon/eraser.png b/resources/eraser.png similarity index 100% rename from src/GUI/icon/eraser.png rename to resources/eraser.png diff --git a/src/GUI/icon/freehand.png b/resources/freehand.png similarity index 100% rename from src/GUI/icon/freehand.png rename to resources/freehand.png diff --git a/src/GUI/icon/line.png b/resources/line.png similarity index 100% rename from src/GUI/icon/line.png rename to resources/line.png diff --git a/src/GUI/icon/oval.png b/resources/oval.png similarity index 100% rename from src/GUI/icon/oval.png rename to resources/oval.png diff --git a/src/GUI/icon/palette.png b/resources/palette.png similarity index 100% rename from src/GUI/icon/palette.png rename to resources/palette.png diff --git a/src/GUI/icon/rectangle.png b/resources/rectangle.png similarity index 100% rename from src/GUI/icon/rectangle.png rename to resources/rectangle.png diff --git a/src/GUI/icon/square.png b/resources/square.png similarity index 100% rename from src/GUI/icon/square.png rename to resources/square.png diff --git a/src/GUI/icon/text.png b/resources/text.png similarity index 100% rename from src/GUI/icon/text.png rename to resources/text.png diff --git a/src/GUI/PaintGUI.java b/src/GUI/PaintGUI.java index 9cfdfd948526d341854121303309ab86590923a7..bf6c13b8510f83203590b7b48f3ee1696b5c4447 100644 --- a/src/GUI/PaintGUI.java +++ b/src/GUI/PaintGUI.java @@ -58,24 +58,15 @@ public class PaintGUI extends JPanel { /// Set up button icons /// try { - String path = System.getProperty("user.dir"); - System.out.println(path); - File palettePic = new File(path + "/src/GUI/icon/palette.png"); - File freehandPic = new File(path + "/src/GUI/icon/freehand.png"); - File linePic = new File(path + "/src/GUI/icon/line.png"); - File circlePic = new File(path + "/src/GUI/icon/circle.png"); - File rectPic = new File(path + "/src/GUI/icon/rectangle.png"); - File ovalPic = new File(path + "/src/GUI/icon/oval.png"); - File eraserPic = new File(path + "/src/GUI/icon/eraser.png"); - File textPic = new File(path + "/src/GUI/icon/text.png"); - BufferedImage paletteIcon = ImageIO.read(palettePic); - BufferedImage freehandIcon = ImageIO.read(freehandPic); - BufferedImage lineIcon = ImageIO.read(linePic); - BufferedImage circleIcon = ImageIO.read(circlePic); - BufferedImage rectIcon = ImageIO.read(rectPic); - BufferedImage ovalIcon = ImageIO.read(ovalPic); - BufferedImage eraserIcon = ImageIO.read(eraserPic); - BufferedImage textIcon = ImageIO.read(textPic); + BufferedImage paletteIcon = ImageIO.read(getClass().getResource("/palette.png")); + BufferedImage freehandIcon = ImageIO.read(getClass().getResource("/freehand.png")); + BufferedImage lineIcon = ImageIO.read(getClass().getResource("/line.png")); + BufferedImage circleIcon = ImageIO.read(getClass().getResource("/circle.png")); + BufferedImage rectIcon = ImageIO.read(getClass().getResource("/rectangle.png")); + BufferedImage ovalIcon = ImageIO.read(getClass().getResource("/oval.png")); + BufferedImage eraserIcon = ImageIO.read(getClass().getResource("/eraser.png")); + BufferedImage textIcon = ImageIO.read(getClass().getResource("/text.png")); + colorPaletteBtn = new JButton(new ImageIcon(paletteIcon)); colorPaletteBtn.addActionListener(actionListener); freehandBtn = new JButton(new ImageIcon(freehandIcon)); diff --git a/src/GUI/StartScreen.java b/src/GUI/StartScreen.java index 6b6a4b53bfb7466916b97ed4f06073b92d3c927c..6b030e1fada0d4a4b0576dbc088fd53aa94b93e8 100644 --- a/src/GUI/StartScreen.java +++ b/src/GUI/StartScreen.java @@ -46,43 +46,47 @@ public class StartScreen { String userName = usernameField.getText(); String password = new String(passwordField.getPassword()); - int connectionStatus = client.connect(userName, serverAddress, password); - - if( connectionStatus == 1 ) - { - frame.setVisible(false); - frame.dispose(); - if (client.getApplicationMain().getFrame() == null) { - client.startApplication(); + if (userName.length() <= 15) { + int connectionStatus = client.connect(userName, serverAddress, password); + if( connectionStatus == 1 ) + { + frame.setVisible(false); + frame.dispose(); + if (client.getApplicationMain().getFrame() == null) { + client.startApplication(); + } + else { + client.clearChat(); + client.clearDrawingArea(); + client.setVisibleApplication(); + } + + } + else if( connectionStatus == 2 || connectionStatus == 6 ) + { + showErrorMessage("Duplicate usernameField: Please enter a new usernameField"); + } + else if( connectionStatus == 3 ) + { + showErrorMessage("Cannot connect to server: Please check the server address"); } - else { - client.clearChat(); - client.clearDrawingArea(); + else if( connectionStatus == 4 ) + { + showErrorMessage("Incorrect Password"); + } + else if( connectionStatus == 5 ) + { + frame.setVisible(false); + frame.dispose(); client.setVisibleApplication(); } - - } - else if( connectionStatus == 2 || connectionStatus == 6 ) - { - showErrorMessage("Duplicate usernameField: Please enter a new usernameField"); - } - else if( connectionStatus == 3 ) - { - showErrorMessage("Cannot connect to server: Please check the server address"); - } - else if( connectionStatus == 4 ) - { - showErrorMessage("Incorrect Password"); - } - else if( connectionStatus == 5 ) - { - frame.setVisible(false); - frame.dispose(); - client.setVisibleApplication(); + else + { + showErrorMessage("Unknown Connection Status"); + } } - else - { - showErrorMessage("Unknown Connection Status"); + else { + showErrorMessage("Username must be less or equal to 15 characters"); } } }