How to dynamically load an image in Crystal 9?

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

Was this solution helpful to you?

Just Added Q & A:

Find solution

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.