Apple Retina Display Support in Java JDK 1.7 for AWT / Swing

风格不统一 提交于 2019-11-28 21:13:36

Java 7u40 Early Access now supports HiDPI (Retina) displays, as shown by this changelog. So retina support is now available on:

  • Java 6
  • Java 7u40ea or greater
  • Java 8

last month I was also interested in the same topic and after some time I found out on net that nobody can answer the question exactly.

There is an open bug for this at Oracle: http://bugs.sun.com/view_bug.do?bug_id=8000629

According to that it should be fixed for Java 1.8. But what I am afraid of is that I am not sure if it also will be fixed for Swing or only for JavaFX. I read somewhere that there is already fix for JavaFX (but not sure if official), which doesn't solve the problem for Swing.

To answer short, after some days of searching on internet unfortunately I couldn't find the answer ...

Regards, Lubos

Retina is fully supported by Oracle starting 1.7.0_40ea. However, there are lacks of APIs for Retina. For instance, there is no support for HiDPIScaledImages like in Apple JDK. You can find some cool tips about Retina support in Oracle JDK here http://bulenkov.com/2013/06/23/retina-support-in-oracle-jdk-1-7/

According to a long thread that I read some months ago (http://lists.apple.com/archives/java-dev/2012/Oct/msg00127.html) the only way to get Retina in Swing is to install the Apple JDK, which in turn just uses a "hack" to make applications retina-compatible. That thread mentions JavaFX as a workaround (which of course is no real workaround when you already have a complex piece of software written in Swing).

I myself tried to write a simple JavaFX application with Java 7 after reading the above thread and it looked sharper on Retina; same with Ensamble (the JavaFX demo application, available on the App Store) which also seemed to render a lot nicer than a normal Swing application (like the Java Control Panel) but perhaps it's just the power of suggestion.

Since I am actively testing each new Java 8 Snapshot release I can also confirm that little to no work has been done to get Swing look passable on retina displays.

Our best bet right now (just an opinion, don't have any secret knowledge) is that someone at Oracle (or a OpenJDK contributor) will buy a retina mac and fix it in Java 8. I don't think Apple will fix it by supplying the Java 6 fixes since the guy from Apple said that they just reverted code related to rendering back to Quartz. It did give the desired result but is heavily tied to proprietary OS X internals which are not being open sourced.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!