On 07/31/2009 02:29 PM, Christopher Deckers wrote:
I may be thinking out loud... but talking about incompatibilities:
In a situation where a container has a JScrollPane with a JComponent
somewhere down its hierarchy,
component.invalidate();
container.validate();
// Use some layout related values immediately
... would not have any effect anymore. Under some certain
circumstances, revalidate is not used because of the fact that the
call is deferred. Maybe for those extreme cases it is desirable to
introduce a method:
public Container getValidateRoot()
That method would never return null unless the component is not
connected to a hierarchy leading to an applet or window. The code
above could be converted to:
component.invalidate();
component.getValidateRoot().validate();
I'm not an expert in Swing, but AFAIK the paradigm used in Swing is
calling the revalidate() method rather than making direct calls to the
validate(). I guess Swing team might provide more details on why it is
more correct.
Anyway, why immediate validation might be needed?
--
best regards,
Anthony