Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What would be getDesktopProperty() for Linux?

I have to read the high contrast mode of the native os and have to apply the settings on my product. Now for windows I have done some thing like this:

 try {
       Toolkit toolkit = Toolkit.getDefaultToolkit();
       boolean highContrast = (Boolean)toolkit.getDesktopProperty("win.highContrast.on" );
 }catch(Exception e) {
 }

This works fine for Windows but I need the desktop property to read linux high contrast settings. Can anyone please tell me what would be the desktop property for linux?

like image 780
Reuben Avatar asked Jul 25 '11 11:07

Reuben


1 Answers

I think there is no good method to check high contrast mode in Linux whenever you using Java or not (X11 itself have no high-contrast feature and Linux have a vast variety of UI frameworks and each of them may implement high contrast in it's own way).

Strictly speaking you'll have a bunch of problems with this in Windows too (see here, or here).

There are two possible options to solve the case: just use system colors in your UI using SystemColor class (if that's just what you need) or use the same class for analyzing a contrast between current foreground and background colors (if you need to know if system colors are high contrast). You can also check the system theme name, but it's quite unreliable method.

like image 179
Konstantin V. Salikhov Avatar answered Nov 11 '22 18:11

Konstantin V. Salikhov