开发者

SWT setForeground in Windows 7 vs. Windows XP

开发者 https://www.devze.com 2023-03-09 16:07 出处:网络
We have SWT apps which use the setForeground method on windows XP, and they work fine.However, running the most recent stable SWT jars and dlls on Win7 seems to show the setForeground method being ign

We have SWT apps which use the setForeground method on windows XP, and they work fine. However, running the most recent stable SWT jars and dlls on Win7 seems to show the setForeground method being ignored. I know that the javadoc says it's a hint, but I wanted to know if this is because something changed between XP and 7, or if it's possible it's a system setting on my new Win7 install.

I had found this post: How to set SWT button foreground color?, but the main answer definitively says that setForeground is ignored on Windows, which isn't true in XP. Also, our problem doesn't seem to be limited to Buttons. Same issues happen with Groups as well.

SWT setForeground in Windows 7 vs. Windows XP

Apparently, a hacky work-around exists by adding a paint listener that manipulates the GC directly to redraw the text with the appropriate color, besides being hacky, this is not practical, because it would mean we开发者_运维问答 had to add this listener to the thousands places where we use Buttons.

Thanks for any help.


This doesn't have anything to do with your system settings. It's just that, as you have guessed, something has changed between XP and 7. Actually, it changed between XP and Vista. Unfortunately there is not much you can do about this, except for the hack that you have mentioned.

For more information, see this bug report.


Further investigation reveals that this is not a difference between XP and Windows 7, but rather the Classic theme vs the Aero or XP theme. If we use the XP theme in XP, Button foreground also cannot be set.

0

精彩评论

暂无评论...
验证码 换一张
取 消