public MBJComponent() {
		mbImage = new MBImage();
		addMouseListener(new MouseAdapter() {
			@Override
			public void mousePressed(final MouseEvent e) {
				if (!selectJulia) {
					if (e.getButton() == MouseEvent.BUTTON1) {
						p1 = e.getPoint();
					}
				}
			}
			
			@Override
			public void mouseClicked (MouseEvent e) {
				if (selectJulia) {
					mbImage = juliaImage;
					selectJulia = false;
					setCursor(Cursor.getDefaultCursor());
					firePropertyChange(POSITION, null, Math.random());
					recalc();
				}
			}
			
			@Override
			public void mouseReleased(final MouseEvent e) {
				if (!selectJulia) {
					if (e.getButton() == MouseEvent.BUTTON1) {
						if (p1 != null && p2 != null) {
							int x1 = Math.min(p1.x, p2.x);
							int y1 = Math.min(p1.y, p2.y);
							int x2 = Math.max(p1.x, p2.x);
							int y2 = Math.max(p1.y, p2.y);
							final Complex o = mbImage.viewToModel(x1, y1, getWidth(), getHeight());
							final Complex s = mbImage.viewToModel(x2, y2, getWidth(), getHeight());
							s.sub(o);
							System.out.println("o=" + o);
							System.out.println("s=" + s);
							mbImage.topLeft = o;
							mbImage.size = s;
							firePropertyChange(POSITION, null, Math.random());
							recalc();
						}
						p1 = null;
						p2 = null;
						repaint();
					}
				}
			}
		});
		addMouseMotionListener(new MouseAdapter() {

			@Override
			public void mouseMoved(final MouseEvent e) {
				if (selectJulia) {
					final Point p = e.getPoint();
					juliaImage = new MBImage(mbImage);
					juliaImage.julia = mbImage.viewToModel(p.x, p.y, getWidth(), getHeight());
					juliaImage.centre();
					final BufferedImage image = (BufferedImage) createImage(TILEWIDTH, TILEHEIGHT);
					MBJFrame.instance.queue.add(new Runnable() {
						@Override
						public void run() {
							// XXX might not be thread safe
							juliaImage.calc(image.getRaster(), 0, 0, TILEWIDTH, TILEHEIGHT);
							images[0][0] = image;
							repaint();
						}
					});
				}
			}
			
			@Override
			public void mouseDragged(final MouseEvent e) {
				if (p1 != null) {
					final Point p = e.getPoint();
					p2 = p;
				}
				repaint();
			}
		});
		addComponentListener(new ComponentAdapter() {
			@Override
			public void componentResized (ComponentEvent e) {
				reimage();
			}
		});
	}