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.
Hello, I have spent about 1 week on solving this problem. Please help me out! After drawing images or shapes on the canvas, I used a windows to cover my drawing. Then when I move the windows away, my image will disappear. WHY?? Please help me??
Joined: Jan 14, 2002
Here is the complete source code if you don't understand what i have just said. http://www.yupapa.com/toybox/demo.java run it and draw on the canvas. Cover it with a windows, it will then erase your drawing. Any ideas how to fix that?
Any time that the system detects an infringement on your java window, it will automatically call update, which clears the window and then calls paint(). ONLY the stuff that has been taken care of in the paint() method of the component will get put back. It is up to the programmer to insure that the paint() method has enough information to completely re-create what was on the component before update() was called. This means taking all that stuff that you have scattered through your mouse methods (2 of which are deprecated by the way) and getting that activity located in the paint() method. Then you have those mouse methods call repaint() - which forces a call to update and paint() and life is good. Of course the challenge is to make sure that the paint() method knows what the state of the drawing was at any given time. This excersize is left to the reader (. . . isn't that fun to say ).
"JavaRanch, where the deer and the Certified play" - David O'Meara
YUPAPA Welcome to the Java Ranch, we hope you’ll enjoy visiting as a regular however, your name is not in keeping with our naming policy here at the ranch. Please re-register under an appropriate name as shown in the policy. Thanks again and we hope to see you around the ranch!! Ryan What cindy is saying is that two of the methods in the code YUPAPA referenced are deprecated. They are the mouseDown and mouseDrag methods. both have been replaced. A deprecated method is one that, although it still works, it has been replaced or there is another newer metho that works better and is reccomended. hope that helps
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com