<AWT Dev> <Swing Dev> Review request #3: 6852592 (revalidate() must be smarter)

Christopher Deckers chrriis at gmail.com
Fri Jul 31 05:59:54 PDT 2009

> 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().

If only all Swing developers knew the Swing paradigm. Also, if Swing
did not expose invalidate() and validate() they would probably not end
up being used by Swing developers. The fact is: some developers do it.

> Anyway, why immediate validation might be needed?

Apart from API misuse, there are certain cases where validating serves
as a hack where deeper refactoring is not possible. I just wanted to
stress that the change we are discussing could break some apps, and
having a getValidateRoot() method would help them move their code to a
working version.

I used validation in a Swing app myself a few days ago where a long
running action is taking place on the EDT (!) but the component
hierarchy was wrongly displayed. I had to perform some validations and
explicit sizing depending on some preferred sizes to adjust the UI
before it blocks. Not validating would end up freezing the UI in a way
that looked pretty ugly to the end user (the no-more-gray-rect
improvement makes the UI remain good). I wish I could refactor the
whole thing so threading is used, but this is a very complex app so
this hack was necessary. In that particular case my code would not
break when changing the rules because I kind of know what I am doing
and I was not validating too high up in the hierarchy. Still, this is
not the case for some apps and code I have seen in the past...

> guess Swing team might provide more details on why it is more correct.

And I am waiting for their input because I sense this change can
affect some existing apps where code does not follow the


More information about the awt-dev mailing list