Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.awt.image.BufferedImage;
- import java.io.*;
- import javax.imageio.ImageIO;
- import javax.swing.JFrame;
- import javax.swing.JPanel;
- public class ImageViewer extends JPanel {
- public static File img;
- public static BufferedImage image;
- public static void main(String[] args) {
- try{
- img = new File("Donk.png");
- image = ImageIO.read(img);
- }catch(IOException e){
- }
- JFrame window = new JFrame();
- window.setSize(500,500);
- window.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- window.add(new ImageViewer());
- window.setVisible(true);
- }
- public void paint(Graphics g){
- super.paint(g);
- g.drawImage(image,100,100,null);
- }
- }
Add Comment
Please, Sign In to add comment