I have set the background on my Jframe with ImageIO and a repaint( drawImage).It works. My JFrame is a JFrame form. When I add more components by dragging them on the Jframe and I run the project, the JFrame display only the first component that I added. The other components are displayed only when I moved the mouse on them. Help???
class Main extends JFrame {
BufferedImage img = null;
Main() {
try {
img = ImageIO.read(new File("sfondo.jpg"));
} catch (Exception e) {
}
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
initComponents();
this.repaint();
setVisible(true);
}
@Override
public void paint(Graphics g) {
g.drawImage(img, 1, 1, null);
}
@SuppressWarnings("unchecked")
public static void main(String[] args) {
Main jrframe = new Main();
}