public void paintComponent(Graphics g) {
    super.paintComponent(g);
    if (_image != null) {
    if (!_autoSize) {
    g.drawImage(_image, _x, _y, _image.getWidth(null), _image.getHeight(null), null);
    }
    else {
    Graphics2D g2d = (Graphics2D) g;
    Double scaleWidth = new Double(getWidth()) / new Double(_image.getWidth(null));
    Double scaleHeight = new Double(getHeight()) / new Double(_image.getHeight(null));
    if (_keepAspect) {
    if (scaleWidth > scaleHeight) {
    scaleWidth = scaleHeight;
    }
    else {
    scaleHeight = scaleWidth;
    }
    }
    g2d.scale(scaleWidth, scaleHeight);
    g2d.drawImage(_image, _x, _y, null);
    }
    }
    }