public static File choose(Component comp, boolean open, String title, String dir, String name, String... extension) {
		StdFileDialog filter = new StdFileDialog(extension);
		FileDialog dialog;
		Window window = WindowUtils.getWindowForComponent(comp);
		int mode = open ? FileDialog.LOAD : FileDialog.SAVE;
		if (window instanceof Frame) {
			dialog = new FileDialog((Frame) window, title, mode);
		} else {
			dialog = new FileDialog((Dialog) window, title, mode);
		}
		dialog.setFilenameFilter(filter);
		dialog.setDirectory(dir);
		dialog.setFile(name);
		dialog.setVisible(true);
		String result = dialog.getFile();
		if (result != null) {
			if (filter.accept(null, result)) {
				File file = new File(dialog.getDirectory(), result);
				RecentFilesMenu.addRecent(file);
				return file;
			} else if (!open) {
				File file = new File(dialog.getDirectory(), PathUtils.enforceExtension(result, extension[0]));
				RecentFilesMenu.addRecent(file);
				return file;
			}
			showCannotOpenMsg(comp, result, null);
		}
		return null;
	}