
org.diirt.datasource.sample.ImagePanel Maven / Gradle / Ivy
The newest version!
/**
* Copyright (C) 2010-18 diirt developers. See COPYRIGHT.TXT
* All rights reserved. Use is subject to license terms. See LICENSE.TXT
*/
package org.diirt.datasource.sample;
import java.awt.Graphics;
import java.awt.Image;
import javax.swing.JPanel;
/**
*
* @author carcassi
*/
public class ImagePanel extends JPanel {
private Image image;
public void setImage(Image image) {
this.image = image;
repaint();
}
public Image getImage() {
return image;
}
@Override
protected void paintComponent(Graphics g) {
if (image != null) {
g.drawImage(image, 0, 0, getWidth(), getHeight(), this);
} else {
g.setColor(getBackground());
g.fillRect(0, 0, getWidth(), getHeight());
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy