private final void initUI()
	{
		// initialize a layout manager:
		this.setLayout(new BorderLayout());

		// create a menu bar:
		JMenuBar menubar = new JMenuBar();
		// ---------------------------------------------------------
		//                 First dropdown menu: "File"
		// ---------------------------------------------------------
		JMenu file = new JMenu("File");
		file.setMnemonic(KeyEvent.VK_F);

		// Set up a save dialog option under the file menu:
		JMenuItem menu_file_save;
		ImageIcon menu_file_save_icon = null;
		try
		{
			menu_file_save_icon = new ImageIcon(getClass().getResource("/SciTK/resources/document-save-5.png"));
			menu_file_save = new JMenuItem("Save", menu_file_save_icon);
		}
		catch(Exception e)
		{
			menu_file_save = new JMenuItem("Save");
		}
		menu_file_save.setMnemonic(KeyEvent.VK_S);
		menu_file_save.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S,Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
		menu_file_save.setToolTipText("Save an image");
		menu_file_save.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				saveImage();
			}
		});
		file.add(menu_file_save);

		// Set up a save data dialog option under the file menu:
		JMenuItem menu_file_save_data;
		try
		{
			menu_file_save_data = new JMenuItem("Save data", menu_file_save_icon);
		}
		catch(Exception e)
		{
			menu_file_save_data = new JMenuItem("Save data");
		}
		menu_file_save_data.setToolTipText("Save raw data to file");
		menu_file_save_data.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				saveData();
			}
		});
		file.add(menu_file_save_data);

		// add a menu item to close the window
		JMenuItem menu_file_exit;
		try
		{
			ImageIcon menu_file_exit_icon = new ImageIcon(getClass().getResource("/SciTK/resources/application-exit.png"));
			menu_file_exit = new JMenuItem("Exit", menu_file_exit_icon);
		}
		catch(Exception e)
		{
			menu_file_exit = new JMenuItem("Exit");
		}
		menu_file_exit.setMnemonic(KeyEvent.VK_X);
		menu_file_exit.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X,Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
		menu_file_exit.setToolTipText("Close window");
		menu_file_exit.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				dispose();
			}

		});
		file.add(menu_file_exit);


		// ---------------------------------------------------------
		//                 Second dropdown menu: "Edit"
		// ---------------------------------------------------------
		JMenu edit = new JMenu("Edit");
		edit.setMnemonic(KeyEvent.VK_E);

		// copy to clipboard
		JMenuItem menu_edit_copy_image;
		ImageIcon menu_edit_copy_icon = null;
		try
		{
			menu_edit_copy_icon = new ImageIcon(getClass().getResource("/SciTK/resources/edit-copy-7.png"));
			menu_edit_copy_image = new JMenuItem("Copy", menu_edit_copy_icon);
		}
		catch(Exception e)
		{
			menu_edit_copy_image = new JMenuItem("Copy");
		}
		menu_edit_copy_image.setMnemonic(KeyEvent.VK_C);
		menu_edit_copy_image.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C,Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
		menu_edit_copy_image.setToolTipText("Copy image to clipboard");
		menu_edit_copy_image.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				copyImage();
			}
		});
		edit.add(menu_edit_copy_image);

		// copy data to clipboard
		JMenuItem menu_edit_copy_data;
		try
		{
			menu_edit_copy_data = new JMenuItem("Copy data", menu_edit_copy_icon);
		}
		catch(Exception e)
		{
			menu_edit_copy_data = new JMenuItem("Copy data");
		}
		menu_edit_copy_data.setToolTipText("Copy data to clipboard");
		menu_edit_copy_data.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				copyData();
			}
		});
		edit.add(menu_edit_copy_data);

		// zoom:
		JMenuItem menu_edit_zoom;
		try
		{
			ImageIcon menu_edit_zoom_icon = new ImageIcon(getClass().getResource("/SciTK/resources/zoom-3.png"));
			menu_edit_zoom = new JMenuItem("Zoom",menu_edit_zoom_icon);
		}
		catch(Exception e)
		{
			menu_edit_zoom = new JMenuItem("Zoom");
		}
		menu_edit_zoom.setMnemonic(KeyEvent.VK_Z);
		menu_edit_zoom.setToolTipText("Set image zoom");
		menu_edit_zoom.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				setZoom();
			}
		});
		edit.add(menu_edit_zoom);


		// ---------------------------------------------------------
		//                 Third dropdown menu: "Analysis"
		// ---------------------------------------------------------
		JMenu analysis = new JMenu("Analysis");
		analysis.setMnemonic(KeyEvent.VK_A);

		// select a point
		JMenuItem menu_analysis_point = new JMenuItem("Select point");
		menu_analysis_point.setToolTipText("Select a point in the image");
		menu_analysis_point.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				selectPoint();
			}
		});
		analysis.add(menu_analysis_point);

		// select a rectangle
		JMenuItem menu_analysis_rectangle = new JMenuItem("Select rectangle");
		menu_analysis_rectangle.setToolTipText("Select a rectangle in the image");
		menu_analysis_rectangle.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				selectRectangle();
			}
		});
		analysis.add(menu_analysis_rectangle);

		// select a circle
		JMenuItem menu_analysis_circle = new JMenuItem("Select circle");
		menu_analysis_circle.setToolTipText("Select a circle in the image");
		menu_analysis_circle.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				selectCircle();
			}
		});
		analysis.add(menu_analysis_circle);

		// Clear all selections
		JMenuItem menu_analysis_clear = new JMenuItem("Clear all");
		menu_analysis_clear.setToolTipText("Clear all selections from image");
		menu_analysis_clear.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent event) {
				clearSelections();
			}
		});
		analysis.add(menu_analysis_clear);



		// ---------------------------------------------------------
		//                 General UI
		// ---------------------------------------------------------
		// Add File to the menu:
		menubar.add(file);
		// Add Edit to the menu:
		menubar.add(edit);
		// Add Analysis to the menu:
		menubar.add(analysis);
		// Set menubar as this JFrame's menu
		setJMenuBar(menubar);

		// call updateUI(), which handles the image stuff.
		if( !(icon_label instanceof JLabel) )
			icon_label = new JLabel();
		icon_label.setHorizontalAlignment(SwingConstants.CENTER);
		add(icon_label,BorderLayout.CENTER);
		updateUI();

		// set size automatically:
		pack();
		// if the window is closed, just dispose it:
		setDefaultCloseOperation(DISPOSE_ON_CLOSE);

		setTitle(title);
		this.setLocationRelativeTo(null);
		this.setVisible(true);
	}