@Override
	public void paintComponent(Graphics g) {
		if ( image == null ) {
			super.paintComponent(g);
			return;
		}
		
		Dimension size = getSize();
		int iw = image.getWidth();
		int ih = image.getHeight();
		
		if ( iw > size.width ) {
			ih *= (double)size.width/iw;
			iw = size.width;
		}
		if ( ih > size.height ) {
			iw *= (double)size.height/ih;
			ih = size.height;
		}
		
		int ix=0;
		int iy=0;
		
		if ( iw < size.width ) {
			ix = (size.width-iw)/2;
		}
		if ( ih < size.height ) {
			iy = (size.height-ih)/2;
		}
		
		g.drawImage(image, ix, iy, iw, ih, this);
	}