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

Alexander Potochkin Alexander.Potochkin at Sun.COM
Tue Jul 28 16:29:02 UTC 2009


Hello Anthony

> Hello Alex,
> 
> On 07/27/2009 10:54 PM, Anthony Petrov wrote:
>>> 1) Bring isValidateRoot() up to the Component class
>>> 2) Make it return false
>>> 3) Leave all other stuff intact
>>
>> The current fix does almost that with a few exceptions. Could you 
>> please describe at what exact cases promoting the isValidateRoot() to 
>> the Component instead of the Container might help? Any concrete 
>> existing methods/examples? Unfortunately I hardly see any, but maybe 
>> it's just me...
> 
> On the second thought, as far as I can grep, I see that currently only 
> RepaintManager.addInvalidComponent(JComponent) uses the isValidateRoot() 
> method. So I assume you mean exactly this piece of code, please correct 
> me if I'm wrong.

That's right

You can also found the similar code in JViewport

> 
> Let me please suggest a couple of possible solutions:
> 
> 1. What about making the 'c' variable a Container instead of the 
> Component at the first loop of the addInvalidComponent() method? Would 
> it require promoting isValidateRoot() up to the Component afterwards? 
> Obviously, no additional type casting or instanceof-checking is required 
> after that change.

Hm, getParent() returns Container?!

You are right my friend, this eliminates my main argument about bringing 
this method to the Component

sorry for confusion
:-)

> 
> 2. What about introducing a Component.getValidateRoot() method instead?
> 

Now I am fine with Container.isValidateRoot()

> I would also like to mention that since you claim that 6862117 is not a 
> bug, then there's actually no any known issue that would require any 
> changes to the addInvalidComponent() right now - generally we don't have 
> any "problem" at all.

I didn't claim that 6862117 is not a bug

I actually said that using Swing components in AWT application is incorrect

a type of an application is defined by the type of the top level windows

AWT application:

awt.JFrame with awt.Button inside - OK
awt.JFrame with swing.JButton inside - not supported

Swing application:

swing.JFrame with swing.JButton - OK
swing.JFrame with awt.Button -
the AWT/Swing mixing case, is going to be supported in JDK7

Swing components need a top level RootContainer for various needs

In the test case for 6862117 I can see that Swing and AWT component
are placed inside JFrame, so this is a valid case

> 
> Given that:
> 
> a) there's already at least three possible solutions to this issue,
> b) the issue is not directly relevant to the aims of the RFE 6852592,
> c) actually the issue is currently quite ephemeral,
> d) the method isValidateRoot() does not seem belonging to the Component 
> class logically for some developers,
> e) the current solution is fully open to any further enhancements and 
> does not bring any restrictions,
> 
> perhaps the discussion regarding further promoting of the method might 
> be postponed till a later date.
> 
> Would you agree?

See my comments above

Thanks
alexp

> 
> -- 
> best regards,
> Anthony




More information about the swing-dev mailing list