Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;

import javax.imageio.ImageIO;
import javax.swing.JFrame;

public class Main extends JFrame {

    private BufferedImage bi;

    public static void main(String[] args) {
        new Main().setVisible(true);
    }

    public Main() {
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        try {
            bi = ImageIO.read(new File("your.jpg"));
        } catch (Exception e) {
            e.printStackTrace();
        }

        setSize(bi.getWidth(), bi.getHeight());
    }

    public void paint(Graphics g) {
        g.drawImage(bi, 0, 0, getWidth(), getHeight(), this);
    }
}