Guest User

Untitled

a guest
Jun 19th, 2018
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. import java.awt.*;
  2. import java.awt.image.BufferedImage;
  3. import java.io.*;
  4.  
  5. import javax.imageio.ImageIO;
  6. import javax.swing.JFrame;
  7. import javax.swing.JPanel;
  8.  
  9. public class ImageViewer extends JPanel {
  10.  
  11. public static File img;
  12. public static BufferedImage image;
  13.  
  14. public static void main(String[] args) {
  15.  
  16. try{
  17.  
  18. img = new File("Donk.png");
  19.  
  20. image = ImageIO.read(img);
  21.  
  22. }catch(IOException e){
  23.  
  24. }
  25.  
  26. JFrame window = new JFrame();
  27. window.setSize(500,500);
  28. window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  29. window.add(new ImageViewer());
  30. window.setVisible(true);
  31.  
  32.  
  33. }
  34. public void paint(Graphics g){
  35. super.paint(g);
  36. g.drawImage(image,100,100,null);
  37. }
  38.  
  39. }
Add Comment
Please, Sign In to add comment