Respuesta :

import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import javax.imageio.ImageIO;
import javax.swing.JFrame;

public class PaintTree extends JFrame {

private static final long serialVersionUID = 1L;
private final String imagePath; // the image path
private BufferedImage image; // image loader

public PaintTree(String imagePath) {
this.imagePath = imagePath;
try {
image = ImageIO.read(new File(imagePath)); // creates the image from path
} catch (IOException e) { e.printStackTrace();
}
}

public void createAndShowGUI() {
setPreferredSize(new Dimension(400, 400)); // sets preferred size for the jframe

setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
pack();
setVisible(true);
}

 // this is automatically called
@Override public void paint(Graphics g) {
super.paint(g);   
    
g.drawImage(image, 0, 0, null); // the method for painting
}

public static void main(String... args) {  
PaintTree pt = new PaintTree("C:\\full\\path\\to\\image"); // set path
 
pt.createAndShowGUI(); // now create the gui
}
}

This is directly copied from my IDE

Hope this helps!
the java script will give you the deta