Java-how i can load a jpg image as background in frame as JFrame class?
-
i have a image like - baby.jpg - i wanna it's be my background in a frame that i creat it as JFrame class but i don't know what i do for this please help me if JFrame win=new JFrame("my window"); how win frame backgrond show baby.jpg image?which method ?please explain
-
Answer:
If you want it as a background, so that you can put other widgets on top, that takes a few tricks. One technique, you subclass JPanel and override the paintComponent(). The photo will paint and then your setLayout() takes over to layout JTextfields, JButtons and whatever else. I'll throw together an example using JLayeredPane, which is part of every JFrame. There is a lot going on under the hood. You load an image using ImageIO.read( file ). A lot of newby problems coding the path to that photo. So, let say that image file is inside a the folder with all your class files. Important, not the folder with your java source files -- the compiled files. good luck.
lidaline at Yahoo! Answers Visit the source
Related Q & A:
- How I can get a cheap train ticket from Munich to Saarbrucken for September? How much is it you think?Best solution by Yahoo! Answers
- Does anyone know how I can get a scholarship to study abroad?Best solution by usnews.com
- How I can send a picture via yahoo mail?Best solution by Yahoo! Answers
- How I can get a job in Indian postal department?Best solution by Yahoo! Answers
- How i can find a friend in yahoo messenger?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.