Questa classe ti permette di inserire un'immagine come sfondo di una finestra, non so se è quello che chiedevi, comunque eccola qui.
Codice PHP:
import java.awt.*;
import javax.swing.*;
public class BackgroundPanel extends JPanel {
public BackgroundPanel(String b) {
super(true);
setOpaque(false);
icon = new ImageIcon(b);
background = icon.getImage();
}
public void paintComponent(Graphics g) {
g.drawImage(background, 0, 0, this);
}
protected ImageIcon icon;
protected Image background;
}
Poi chiami questa classe nel costruttore del tuo JFrame con:
Codice PHP:
JPanel backgroundPanel = new BackgroundPanel("sfondo.jpg");
getContentPane().add(backgroundPanel);