void select_imagesource(String direction) {

		if (this.image_file != null) {
			File file = null;
			File folder = image_file.getParentFile();
			File[] listOfFiles = folder.listFiles();
			HashMap<String, File> imageFiles = new HashMap<String, File>();
			for (int i = 0; i < listOfFiles.length; i++) {
				file = listOfFiles[i];
				if (file.isFile() && (
					file.getName().toLowerCase().endsWith(".jpg") ||
					file.getName().toLowerCase().endsWith(".png"))) {
					imageFiles.put(file.getName(), file);
				}
			}
			Object[] keys = imageFiles.keySet().toArray();
			// Sort the keys so the files are ordered
			Arrays.sort(keys);
			int index = Arrays.asList(keys).indexOf(image_file.getName());
			int next_index = (direction == "prev" ? index-1: index+1);
			if (next_index >= keys.length)
				next_index = 0;
			else if (next_index < 0)
				next_index = keys.length-1;
			String nextfile = null;
			try {
				image_file = imageFiles.get(keys[next_index]);
				nextfile = image_file.getCanonicalPath();
				updateImageSource(new ImageSource(nextfile));
				statusBar.setText("Opened " + image_file.getName());
				this.imageMap.setSrc(image_file.getName());
				//jTabbedPane1.setTitleAt(0, image_file.getName());
				// currentFile.setText(image_file.getName());
			}
			catch (Exception ex) {
				statusBar.setText("Exception getting "+direction+" image");
	        }
		}
		else
			statusBar.setText("no image file is currently open");
	}