This week's book giveaway is in the OCPJP forum. We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line! See this thread for details.
i m not able to set a background image of my JPanel, can anyone tell me how do i set JPanel Background image??
here is my code, in which i m setting the background color of my JPanel but i want to set an image instead:
First of all getResource() already returns a URL, so wrapping it in a URL seems pointless. And using the URL constructor which gets a relative URL for a resource with the same name also seems pointless. But the real problem is that getResource doesn't take a file path in the first place. If you want to use a file path, a File object is the thing to use. The getResource() method is for finding resources in the classpath. So use a File object.
okay i will..
one more thing i really want to know always, and i believe you can help me in that also,
which is the best way to read javadoc??
because javadoc always provides only classes,methods,constructor etc.
and most of times i don't know how to use most of them even..
You should never load any resources in any painting method. paintComponent may be called multiple times per second, and that will slow down painting significantly. You should instead load the image in the constructor and keep a reference to it.