This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
I've got a JFrame that draws an image, but as soon as the image is drawn, the window repaints. How do I force the image to remain drawn? The image is drawn in a method, and as soon as that method exits, the frame is emptied.
Put the image drawing code in the paint() or paintComponent() method. If you're painting to the component anywhere else it won't be a lasting change (as you've found).
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
Joined: Sep 09, 2003
How do I override the paint method for only one JFrame? I might have forgotten to mention it in my first post, I've got two JFrames which will be visible at the same time, if I override paint, won't it paint the image over both frames? As for code, I don't know if there is anything spectacular about it that will highlight my problem. What I do is create the image, then draw it on the JFrame jf_work using jf_work.drawImage(bi, 0, 0, this);