uckelman uckelman - 1 year ago 105
Java Question

How can I detect whether a Mac has a Retina display from Java?

I've found a Swing image rendering bug which afflicts only Macs with Retina displays (

fail to draw). I have an effective workaround (use
images instead), but in order to apply it, I need to be able to detect whether the host machine is a Mac with a Retina display. Detecting whether the machine is a Mac is no problem, but how can I determine the display type?

job job
Answer Source


The above line should return 2.0 on retina displays. On more recent non-retina macs it returns 1.0 and on all other platforms you get back null. I can't find any official documentation, but I ran across it in this mailing list post while trying to solve a similar problem.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download