ImagePanel.java added to display images

This commit is contained in:
ericnerdo 2016-05-07 13:28:42 +02:00
parent 85ed728124
commit d228415e41

View File

@ -0,0 +1,28 @@
package cicaprojekt;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JPanel;
public class ImagePanel extends JPanel{
private BufferedImage image;
public ImagePanel(String path) {
try {
image = ImageIO.read(new File(path));
} catch (IOException ex) {
}
}
@Override
protected void paintComponent(Graphics g) {
super.paintComponent(g);
g.drawImage(image, 0, 0, null); // see javadoc for more info on the parameters
}
}