This week's book giveaway is in the OCMJEA forum. We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line! See this thread for details.
I've followed the thread to create a panel with a background image and everythign is working except loading the image.
The getResource calls work fine in both cases and return the proper path for the png I'm trying to load- but, the beginning of the URL string contains "file:" before the first slash. The imageIO.read call always returns null, and I'm suspecting it's because of the file: tag at the beginning of the URL. What is the proper way I should be finding the resource and passing the string to imageIO?
To insert a image in the background of JPanel, clickhere.
But you can do this using JLabel too. It's easy than this..
Joined: May 15, 2013
Thanks- that is exactly the JPanel code I am using. My problem though is that the imageIO.read call is not working. The url string has "file://.....pathname" and the read call always returns null as though it can't find the file. I'm suspecting it is because of the "file:" tag prepended to the path. That actual pathname is correct and the image file is indeed there.
What I'm trying to layout is a GUI that has a panel across the top of the frame that contains an image for the background, and then I want to paint other transparent images on top of this background that will act as buttons.