Zde je nějaký easy zdrojak, snad ti to helpne
Samozřejmě je nutné změnit název obrázku a správně nastavit cestu.
import java.awt.*;
import java.io.*;
import javax.imageio.*;
import javax.swing.*;
public class H11_JFramePozadi extends JFrame {
private static final long serialVersionUID = 7357954185642642965L;
static {
try {
UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); }
catch (ClassNotFoundException | InstantiationException | IllegalAccessException | UnsupportedLookAndFeelException ex) {
ex.printStackTrace(); } }
private H11_JFramePozadi() { // konstruktor
try {
super.setTitle("Program na nacteni obrazku jako pozadi");
JLabel obrazek = new JLabel(new ImageIcon(ImageIO.read(new File("kocka.jpg"))));
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.setContentPane(obrazek);
this.setLayout(null);
JLabel text = new JLabel("Hello from the foreground");
text.setForeground(Color.RED);
text.setBounds(20,50,200,150);
JButton tlacitko = new JButton("OK-test");
tlacitko.setBounds(20,250,200,150);
this.add(text);
this.add(tlacitko);
this.pack();
this.setLocationRelativeTo(null); }
catch (IOException | HeadlessException exp) {
exp.printStackTrace(); } }
public static void main(String [] args) {
new H11_JFramePozadi().setVisible(true); }
}