Hello, I have developed a JFrame in swing. I have the problem that the paintComponent function is called more than 50 times a second without a single repaint() anywhere. Please help me to find why it is repainting like crazy. Thanks.
I was suspicious of the repaint call in the code below but now it doesn't look so bad after I formatted it. You might try putting a System.out.println inside this and other event handlers to see if they are being called too much.
If you do things right there should not be a need to call repaint at the end (after win.pack). I would go thru your code and comment out every call to repaint in an attempt to stop the repainting. And make sure you don't have a repaint inside any paint or paintComponent methods. [ January 24, 2004: Message edited by: Craig Wood ]
Joined: Jan 24, 2004
Thank you very much for your help. IT HAS SOLVED THE PROBLEM!!! I have commented out all the repaint() calls and now there is only repaint when I hide and show back the window. I think it was this final repaint call after win.pack; I will check it now by uncommenting the actionlistener repaint calls. It has also solved the problem of my button being not visible. NOW EVERYTHING IS PERFECT. THANKS!!! ps: now the problem is going to be how to refresh when new data comes. ha ha.