From 1c847c06ae3475483b249ae4edc441a83a4fa0b6 Mon Sep 17 00:00:00 2001 From: ericnerdo Date: Sat, 7 May 2016 14:45:58 +0200 Subject: [PATCH] void changeImage(String path) added to ImagePanel. --- cicaprojekt/ImagePanel.java | 6 +++++- cicaprojekt/WallDrawer.java | 1 + 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/cicaprojekt/ImagePanel.java b/cicaprojekt/ImagePanel.java index d7fd475..243a779 100644 --- a/cicaprojekt/ImagePanel.java +++ b/cicaprojekt/ImagePanel.java @@ -21,5 +21,9 @@ public class ImagePanel extends JPanel{ super.paintComponent(g); g.drawImage(image, 0, 0, null); // see javadoc for more info on the parameters } - + + public void changeImage(String path) throws IOException { + image = ImageIO.read(new File(path)); + repaint(); + } } \ No newline at end of file diff --git a/cicaprojekt/WallDrawer.java b/cicaprojekt/WallDrawer.java index f5202a9..7d5aabd 100644 --- a/cicaprojekt/WallDrawer.java +++ b/cicaprojekt/WallDrawer.java @@ -14,6 +14,7 @@ public class WallDrawer extends ImagePanel implements Drawer { @Override public void draw() { + setVisible(true); }