<Swing Dev> Background/Foreground colors and Gtk Look and Feel

Omair Majid omajid at redhat.com
Thu Jan 22 15:40:44 UTC 2009


Hi Kirill,

Kirill Kirichenko wrote:
> Hi Omar
> Sorry for delay from out side.
> I'm a responsible engineer for GTK L&F.
> 

No problem. I am just glad I am getting a response from someone who 
knows this stuff.

> 
> Omair Majid wrote:
>> I have noticed a few issues in the Gtk Look and Feel and would like to 
>> know what the correct behaviour should be. The attached program shows 
>> a few of my concerns.
>>
>> 1) For each of the components, setForeground(color) and/or 
>> setBackground(color) assignments are randomly ignored. Is this the 
>> expected behaviour? I can understand that using the native look and 
>> feel, the feel is exactly preserved and the programmer's preferences 
>> are ignored. But there doesn't seem to be any consistency - some 
>> components accept the color changes, some silently ignore it. Is there 
>> a list showing whether setForeground() and setBackground() is ignored 
>> for each swing component with the gtk look and feel?
> Generally GTK L&F leverages theme settings for colors, indents and 
> fonts. And you shouldn't be able to change them using standard swing API 
> when GTK L&F is active. Sometimes this does work but you shouldn't use 
> this feature. This is the policy for GTK L&F. Actually the have been 
> similar requests and I tried to resolve the issue. The thing is GTK 
> itself doesn't allow changing colors freely for all components it just 
> uses the theme settings.

So the _correct_ behaviour is that setBackground()/setForeground() are 
ignored completely? So if a component actually responds to 
setBackground() or setForeground(), it's a bug?

> 
> 
>> 2) The behaviour varies across jdk6 and openjdk6. For example, the 
>> closed-source jdk6 respects 
>> JTextPane.setBackground(UIManager.getColor("Panel.background")) but 
>> openjdk6 ignores it. In situations like this, what is the correct 
>> behaviour? Should I attempt to patch openjdk6 to behave more like 
>> closed source jdk6?
> It may happen because the codebases slightly different. I haven't 
> applied all fixes to openjdk6 which I have to jdk6.
> 
> Hope that helps.

I am still a little confused. If closed source jdk allows setting the 
background, and openjdk doesn't, doesn't that mean openjdk is correct 
and the fixes should be applied to the closed source jdk? Basically, I 
am asking what the ideal behaviour should be. Should 
setBackground()/setForeground() have any effect when using the gtk look 
and feel?

Cheers,

Omair



More information about the swing-dev mailing list