public static void openFile(File file, Codec[] codecs) {
		ParseException p = null;
		for (int i = 0; i < codecs.length; i++) {
			try {
				Serializable object = codecs[i].decode(file, null);
				if (openOrRead && !(object instanceof TuringMachine)) {
                    JOptionPane.showMessageDialog(null,
                            "Only Turing Machine files can be added as building blocks.", "Wrong File Type",
                            JOptionPane.ERROR_MESSAGE);
                    return;
					
				}
				lastObject = object;
				lastFile = file;
				// Set the file on the thing.
				if (!openOrRead) {
					EnvironmentFrame ef = FrameFactory.createFrame(object);
					if (ef == null)
						return;
					ef.getEnvironment().setFile(file);
					ef.getEnvironment().setEncoder(
							codecs[i].correspondingEncoder());
				}
				return;
			} catch (ParseException e) {
				p = e;
			}
		}
		if (codecs.length != 1)
			p = new ParseException("No format could read the file!");
		throw p;
	}