简体   繁体   中英

Java: Get windows color

I'll be brief: How do I get the color that the user can specify on the windows platform? On windows 10 it's the color of the tiles when you open the start menu. SystemColor doesn't work, it just returns the color 153 180 209 (a light blue) for SystemColor.activeCaption no matter what the setting is set to on every version of windows. UIManager is practically useless. The names of the keys seem to be different on every version of windows. It seems that SystemColor works on Mac and Linux. Any ideas as to how I get this color? Thanks.

Found out how to do this recently. There is a value in the windows registry called HKEY_CURRENT_USER\\Software\\Microsoft\\Windows\\DWM\\AccentColor , that stores the system window title color. You can use JNA's Advapi32Util to read the value from the Windows registry.

You can then use a graphics library like java.awt.Color to convert the color into RGB values.

There is an implementation of this here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM