+
+
+ /**
+ * Set the frame bounds using the saved config setting
+ * @param inFrame frame to set the bounds of
+ * @return true on success
+ */
+ private static boolean setFrameBoundsFromConfig(JFrame inFrame)
+ {
+ // Try to get bounds from config
+ String bounds = Config.getConfigString(Config.KEY_WINDOW_BOUNDS);
+ try
+ {
+ String[] boundValues = bounds.split("x");
+ if (boundValues.length == 4)
+ {
+ int[] elems = new int[4];
+ for (int i=0; i<4; i++) {
+ elems[i] = Integer.parseInt(boundValues[i]);
+ }
+ // Make sure width and height aren't stupid
+ elems[2] = Math.max(elems[2], 400);
+ elems[3] = Math.max(elems[3], 300);
+ inFrame.setBounds(elems[0], elems[1], elems[2], elems[3]);
+ return true;
+ }
+ }
+ catch (NullPointerException npe) {} // if no entry found in config
+ catch (NumberFormatException nfe) {} // if string couldn't be parsed
+ return false;
+ }
+
+
+ /**
+ * Try to guess whether it's a mistyped parameter or a mistyped filename
+ * @param inParam command line argument
+ * @return error message
+ */
+ private static String makeUnknownParameterString(String inParam)
+ {
+ File file = new File(inParam);
+ if (file.exists())
+ {
+ if (file.isDirectory()) return "'" + inParam + "' is a directory";
+ if (!file.canRead()) return "Cannot read file '" + inParam + "'";
+ return "Something wrong with file '" + inParam + "'";
+ }
+ do
+ {
+ String name = file.getName();
+ file = file.getParentFile();
+ if (file != null && file.exists() && file.canRead()) return "Tried to load file '" + inParam + "' but cannot find '" + name + "'";
+ }
+ while (file != null);
+
+ return "Unknown parameter '" + inParam + "'";
+ }