X-Git-Url: http://challenge-bot.com/repos/?a=blobdiff_plain;f=ShowImage.java;h=8a0adc7c4bc5af9ebd4e6bdb2a8ad379d4336a2e;hb=b0441b26916beaddbd3ce54d2cf9148fb18ab933;hp=91c307253dc2bb2356629ef826fca995adde042e;hpb=eea7473f4df5860f76fc7f5ef219c76cb10b3efe;p=3501%2FOpenCVShowImage diff --git a/ShowImage.java b/ShowImage.java index 91c3072..8a0adc7 100644 --- a/ShowImage.java +++ b/ShowImage.java @@ -9,51 +9,51 @@ import javax.imageio.ImageIO; import javax.swing.JFrame; public class ShowImage extends Panel { - BufferedImage image; - - public ShowImage() { - try { - // image file - // name is - // test.png - URL input = this.getClass().getResource(("test.png")); - // this will read the image to save - // into a BufferedImage variable - image = ImageIO.read(input); - } catch (IOException ie) { - // this is to spill - // out a message - // saying - // something - // doesn't work - System.out.println("Error: " + ie.getMessage()); - } - } - - public void paint(Graphics g) { - // This is to actually draw the image out, - // necessary. - - // Input of a bufferedimage, x, y, then - // an observer in this case null. - g.drawImage(image, 0, 0, null); - } - - static public void main(String args[]) throws Exception { - // Creates a window to - // display the image - JFrame frame = new JFrame("Display image"); - - // Gets the image from ShowImage() method - Panel panel = new ShowImage(); - - // Adds the image to the new window - // panel - frame.getContentPane().add(panel); - - // sets the size of the panel - frame.setSize(500, 500); - // makes it visible - frame.setVisible(true); - } + BufferedImage image; + + public ShowImage() { + try { + // image file + // name is + // test.png + URL input = this.getClass().getResource(("imgs/test.png")); + // this will read the image to save + // into a BufferedImage variable + image = ImageIO.read(input); + } catch (IOException ie) { + // this is to spill + // out a message + // saying + // something + // doesn't work + System.out.println("Error: " + ie.getMessage()); + } + } + + public void paint(Graphics g) { + // This is to actually draw the image out, + // necessary. + + // Input of a bufferedimage, x, y, then + // an observer in this case null. + g.drawImage(image, 0, 0, null); + } + + static public void main(String args[]) throws Exception { + // Creates a window to + // display the image + JFrame frame = new JFrame("Display image"); + + // Gets the image from ShowImage() method + Panel panel = new ShowImage(); + + // Adds the image to the new window + // panel + frame.getContentPane().add(panel); + + // sets the size of the panel + frame.setSize(500, 500); + // makes it visible + frame.setVisible(true); + } }