I'm trying to set a png file as a jframe form's background like this sw, so to do this, I just create the jframe form Test2 and call it with:
public static void main(String[] args) {
Test2 t2 = new Test2();
t2.setOpacity(0.55f);
t2.setVisible(true);
}
In the java class, Test2, set as undecorated, and set a image in a panel as a example, but I don't it there anymore, how can I set it as a background of all my panels/jframe form?
public Test2() {
setUndecorated(true);
initComponents();
Imagen imagen = new Imagen();
panel1.add(imagen);
panel1.repaint();
}
Imagen class:
public class Imagen extends JPanel{
public Imagen() {
this.setSize(905, 488); //se selecciona el tamaño del panel //[767, 481]
}
//Se crea un método cuyo parámetro debe ser un objeto Graphics
public void paint(Graphics grafico) {
Dimension height = getSize();
//Se selecciona la imagen que tenemos en el paquete de la //ruta del programa
ImageIcon Img = new ImageIcon(getClass().getResource("/images/reborn.png"));
//se dibuja la imagen que tenemos en el paquete Images //dentro de un panel
grafico.drawImage(Img.getImage(), 0, 0, height.width, height.height, null);
setOpaque(false);
super.paintComponent(grafico);
}
}