In Java Swing, you need to add a picture to the container, or a background picture.
Offers two simple solutions, one using JPanel and the other using JLabel
1.JPanel (source code)
[Java] View plain copy package oo; import java.awt.graphics; Import java.awt.Image; import java.io.file; import javax.swing.imageicon; import javax.swing.jframe; import javax.swing.JPanel; public class drawing { Jframe jframe = new jframe (); public static jpanel gimage = null; public drawing () { initframe (); } // Initialization window public void initframe () { // Use JPanel to add a background picture  &NBsp gimage = new jpanel () { protected void paintcomponent (graphics g) { imageicon icon = new imageicon ("image\\ Benbenla.jpg "); image img = icon.getimage (); g.drawimage (img, 0, 0, Icon.geticonwidth (), icon.geticonheight (), Icon.getimageobserver ()); jframe.setsize ( Icon.geticonwidth (), icon.geticonheight ()); } } ; jframe.settitle ("Test background picture"); jframe.add (gimage); jframe.pack (); jframe.setvisible (true); jframe.setdefaultcloseoperation (JFrame.EXIT_ON_ Close); } public static void main (String[] args) { new drawing (); } }
2.JLabel Source Code
[Java] view plain copy package Swing.draw; Import Java.awt.Image;