JPanel background image

Posted by Zloy Smiertniy on Stack Overflow See other posts from Stack Overflow or by Zloy Smiertniy
Published on 2010-05-30T03:18:53Z Indexed on 2010/05/30 3:22 UTC
Read the original article Hit count: 343

Filed under:
|
|
|

This is my code, it indeed finds the image so that is not my concern, my concern is how to make that image be the background of the panel. I'm trying to work with Graphics but i doesnt work, any ideas?? please??

try {
            java.net.URL imgURL = MAINWINDOW.class.getResource(imagen);

            Image imgFondo = javax.imageio.ImageIO.read(imgURL);
            if (imgFondo != null) {
                Graphics grafica=null;
                grafica.drawImage(imgFondo, 0, 0, this);
                panel.paintComponents(grafica);
            } else {
            System.err.println("Couldn't find file: " + imagen);
            }

        } catch...

© Stack Overflow or respective owner

Related posts about java

Related posts about image