Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When does one need to call revalidate() on a swing component to make it refresh, and when not?

When dealing with swing components, and when changing the components during runtime, one (often) needs to call the revalidate() method on the components in order for them to refresh.

What are the rules that determine whether or not one needs to revalidate a component? Does swing automatically call revalidate() when some certain properties on a component changes, and for some other properties not?

like image 899
Datoraki Avatar asked Apr 24 '11 09:04

Datoraki


1 Answers

The basic rule is: never - swing internals will take care of it. The basic exception to the rule is adding/removing components at runtime or changes which effect layout in ways the system can't know or for some reason doesn't want to react to.

While the exception is not very clearcut, it's infrequency in "normal" application development is: if there's a need to "often" call it there's a high probability something wrong with the code, f.i. a custom model implementation not notifying its listeners.

like image 64
kleopatra Avatar answered Sep 24 '22 06:09

kleopatra