How do you discover Retina Display in Java?

How to determine if a user has retina mapping in Java? I already know about scaling factor detection using Toolkit.getDefaultToolkit().getDesktopProperty("apple.awt.contentScaleFactor") , but java won't let me convert the return value to int. I am wondering how I can convert this to int or another way to detect retinal mappings.

+7
java retina-display
source share
1 answer

I would get the value this way -

 public static boolean hasRetinaDisplay() { Object obj = Toolkit.getDefaultToolkit() .getDesktopProperty( "apple.awt.contentScaleFactor"); if (obj instanceof Float) { Float f = (Float) obj; int scale = f.intValue(); return (scale == 2); // 1 indicates a regular mac display. } return false; } 
+5
source share

All Articles