Tengo este código, pero no se qué es lo que estoy haciendo mal:
Código:
import java.awt.Color;
import java.awt.Container;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
public class mainClass extends JFrame {
private static final long serialVersionUID = 1L;
Container cont = new Container();
JPanel fondo = new JPanel();
ImageIcon Imagen = new ImageIcon("imagen.png");
JLabel Img = new JLabel();
public mainClass(){
this.setBounds(100,100,640,480);
this.setVisible(true);
this.add(cont);
cont.add(fondo);
Img.setVisible(true);
Img.setLocation(200,200);
Img.setSize(100,100);
Img.setIcon(Imagen);
Img.setOpaque(true);
fondo.setBounds(0,0,500,300);
fondo.setVisible(true);
fondo.setLocation(100,100);
fondo.setBackground(Color.blue);
fondo.add(Img);
}
public static void main(String[] args){
mainClass window = new mainClass();
window.setTitle("Mi título");
}
}


