/* * You might regard it as somewhat excessive to test the file here, but * path errors (or rather, assumptions about what the current working * directory is turning out to wildly wrong) are so common that we help * out beginners by guarding. */ public void addFromFile(String filename) throws FileNotFoundException, ParseException { final File target; if (filename == null) { throw new IllegalArgumentException(); } target = new File(filename); if (!target.exists()) { throw new FileNotFoundException( "\nCan't find the specified Glade UI file:\n" + target.getAbsolutePath()); } if (!target.canRead()) { throw new FileNotFoundException( "\nThe specified Glade UI file,\n" + target.getAbsolutePath() + "\nis not readable"); } try { GtkBuilder.addFromFile(this, filename); } catch (GlibException e) { throw new ParseException(e.getMessage(), 0); } }