From d228415e41c48d1dfd00ce833b3ebc688eb11d8a Mon Sep 17 00:00:00 2001 From: ericnerdo Date: Sat, 7 May 2016 13:28:42 +0200 Subject: [PATCH] ImagePanel.java added to display images --- cicaprojekt/ImagePanel.java | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 cicaprojekt/ImagePanel.java diff --git a/cicaprojekt/ImagePanel.java b/cicaprojekt/ImagePanel.java new file mode 100644 index 0000000..2085226 --- /dev/null +++ b/cicaprojekt/ImagePanel.java @@ -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 + } + +} \ No newline at end of file