| Author |
How to: call repaint() 4 times from other class.
|
Aji Prasetyo
Ranch Hand
Joined: Jun 13, 2007
Posts: 65
|
|
Hi all, I have a question about calling repaint() method from other class. The problem is that I can't call repaint() 4 times from other class. The result is always something like this:
trying to repaint() 1 times... trying to repaint() 2 times... trying to repaint() 3 times... trying to repaint() 4 times... trying to repaint() 5 times... Actually doing repaint() 5 times...
Below I have included the code I am talking about. I am sorry for the trouble but thank you beforehand.
|
 |
Aji Prasetyo
Ranch Hand
Joined: Jun 13, 2007
Posts: 65
|
|
The problem is that I can't call repaint() 4 times from other class.
I meant 5 times, sorry. My preferred result would be: trying to repaint() 1 times... Actually doing repaint() 1 times... trying to repaint() 2 times... Actually doing repaint() 2 times... trying to repaint() 3 times... Actually doing repaint() 3 times... trying to repaint() 4 times... Actually doing repaint() 4 times... trying to repaint() 5 times... Actually doing repaint() 5 times... Any help would be greatly appreciated.
|
 |
Brian Cole
Author
Ranch Hand
Joined: Sep 20, 2005
Posts: 852
|
|
You seem to be under the impression that each call to repaint() results in a call to paint()/paintComponent(). This is not the case, which is a good thing. In general we like that mulitple calls to repaint() may be coalesced into a single paint()/paintCoponent() call. It keeps our GUIs responsive. So, why are you trying to do this? (If you are trying to achieve an animation effect, then you probably want to call repaint() from a timer.) [edit: Looking more closely at your code, I see I may have misjudged your problem. For example, with new ViewControl(rdius).repaint() you are requesting that a newly-instantiated ViewControl object (which is not added to any container) repaint itself. It seems what you really want to do is call myExistingViewControl.repaint(), where myExistingViewControl is a reference to a single ViewControl object that you have already added to some visible container.] [ October 08, 2007: Message edited by: Brian Cole ]
|
bitguru blog
|
 |
 |
|
|
subject: How to: call repaint() 4 times from other class.
|
|
|