public ImagePanel(ImageBrowser2DGui g, Image i, int x, int y, int width, int height) {

		super(true);

		this.gui = g;

		this.image = i;

		Dimension d = new Dimension(width, height);
		setSize(d);
		setMaximumSize(d);
		setMinimumSize(d);
		setPreferredSize(d);
		setForeground(Color.white);
		setBackground(Color.black);
		setOpaque(true);

		setBounds(x, y, width, height);

		if(gui.mainPanelViewMode == ImageBrowser2DGui.VIEW_MODE_MULTI) {
			if (image.selected) {
				setBorder(BorderFactory.createLineBorder(Color.RED, 2));
			} else {
				setBorder(BorderFactory.createLineBorder(Color.WHITE, 2));
			}
		}

		addMouseListener(new MouseListener() {

			@Override
			public void mouseReleased(MouseEvent e) {
			}


			@Override
			public void mousePressed(MouseEvent e) {
			}


			@Override
			public void mouseExited(MouseEvent e) {
				if (!contains(e.getPoint())) {
//					setBackground(Color.BLACK); TODO
					tagImageButton.setVisible(false);
				}
			}


			@Override
			public void mouseEntered(MouseEvent e) {
//				setBackground(Color.DARK_GRAY); TODO
				tagImageButton.setVisible(true);
			}


			@Override
			public void mouseClicked(MouseEvent e) {
				
				gui.leadSelection = image.image_id;
				
				if(e.getClickCount() == 2) {
					gui.switchView();
					return;
				}
				
				if (e.isControlDown()) {
					image.selected = !image.selected;
				}
				else if (!image.selected) {
					gui.deselectAll();
					image.selected = true;
				}
				
				if (gui.mainPanelViewMode == ImageBrowser2DGui.VIEW_MODE_MULTI) {
					if (image.selected) {
						setBorder(BorderFactory.createLineBorder(Color.RED, 2));
					}
					else {
						setBorder(BorderFactory.createLineBorder(Color.WHITE, 2));
					}
				}
			}
		});

		calcImageSizes();

		selectImageSizing();

		ImageWorker imageWorker = new ImageWorker();
		imageWorker.execute();

		tagImageButton = new JButton("...");
		tagImageButton.addActionListener(new ActionListener() { // TODO
					@Override
					public void actionPerformed(ActionEvent arg0) {
						gui.showUserMessage("click");
					}
				});
		tagImageButton.setVisible(false);

		String columnSpecs = "3dlu, pref, 3dlu, pref:GROW, 3dlu, pref, 3dlu";
		String rowSpecs = "3dlu, pref, 3dlu, pref:GROW, 3dlu, pref, 3dlu";
		FormLayout layout = new FormLayout(columnSpecs, rowSpecs);
		layout.setColumnGroups(new int[][] { { 2, 6 } });
		layout.setRowGroups(new int[][] { { 2, 6 } });
		setLayout(layout);

		PanelBuilder builder = new PanelBuilder(layout, this);
		CellConstraints cc = new CellConstraints();

		builder.add(tagImageButton, cc.xy(6, 6));
	}