Apple Retina显示屏支持Java JDK 1.7中的AWT / Swing

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

I just became aware that AWT / Swing under Java JDK 1.7 (as of JDK 7u15) does not support Retina displays on Apple Macbook Pros. Netbeans, for example, is nearly unbearable to use for more than a few minutes running on a Retina display and using JDK 1.7.

我刚刚意识到,Java JDK 1.7 (JDK 7u15)下的AWT / Swing不支持苹果Macbook pro上的Retina显示。例如,在视网膜显示屏上运行几分钟,使用JDK 1.7,几乎无法使用Netbeans。

This has been somewhat addressed in a StackExchange question here, and quoting one specific post:


Apple's Java 6 JRE will support HiDPI, however it is not currently supported by Oracle's Java 7 JRE. It also doesn't work under the latest dev builds of Java 8. Swing and JavaFX apps are blurry on a Retinia MacBook. This is why IntelliJ still runs under Java 6.

苹果的Java 6 JRE将支持HiDPI,但是目前Oracle的Java 7 JRE并不支持HiDPI。在Java 8的最新开发版本中,它也不能工作。在Retinia MacBook上,Swing和JavaFX应用程序都很模糊。这就是为什么IntelliJ仍然在Java 6下运行。

My question is more specific than what is asked by the OP of the above thread.


My employer of less than a month uses Swing in all of its applications. For several reasons we are interested in migrating to Java 7 from Java 6. Within the last several days, another developer (who is on Windows), moved our platform over to Java 7. As I'm running a retina Macbook Pro, I noticed the issue when I pulled the latest stable branch of our code.

我的雇主在不到一个月的时间里使用了Swing的所有应用。出于几个原因,我们希望从Java 6迁移到Java 7。在过去的几天里,另一位开发人员(他在Windows上)将我们的平台转移到了Java 7。当我运行retina Macbook Pro时,我发现了这个问题,当我拉出我们代码的最新稳定分支时。

I am new to Java with less than a year of experience in the community, hence my question: Will the Java community be fairly responsive to this issue moving forward, or should a substantial delay be anticipated (months to a year or more) before Swing in Java 7 is compatible with Apple Retina displays?

我不到一年的新Java社区的经验,因此我的问题:将Java社区相当前进回应这个问题,或者大量延迟应该预期(个月到一年或更多)摇摆在Java 7兼容苹果视网膜显示吗?

4 个解决方案



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

Java 7u40早期访问现在支持HiDPI (Retina)显示,如图所示。所以视网膜支持现在可以使用:

  • Java 6
  • Java 6
  • Java 7u40ea or greater
  • Java 7 u40ea或更大
  • Java 8
  • 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:


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.

根据这一点,它应该被固定为Java 1.8。但我担心的是,我不确定它是否也将用于Swing,还是仅用于JavaFX。我在某处读到过关于JavaFX的修正(但不确定是否是官方的),这并不能解决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

Oracle从1.7.0_40ea开始完全支持视网膜。然而,视网膜缺乏api。例如,不像在Apple JDK中那样支持HiDPIScaledImages。您可以在Oracle JDK中找到关于视网膜支持的一些很酷的提示: support-jdk -1-7/。



According to a long thread that I read some months ago ( 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).

根据我几个月前读过的一篇文章(,让Retina进入Swing的唯一办法是安装Apple JDK,而JDK只是使用“hack”使应用程序兼容视网膜。这个线程提到JavaFX是一个解决方案(当然,当您已经用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.

在阅读了上面的线程之后,我尝试用Java 7编写一个简单的JavaFX应用程序,它在Retina上看起来更清晰;Ensamble也一样(JavaFX演示应用程序,可以在应用商店中找到),它看起来比普通的Swing应用程序(比如Java控制面板)要好得多,但也许这只是建议的力量。

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.

由于我正在积极地测试每一个新的Java 8快照发行版,我还可以确认,在retina显示屏上,还没有做多少工作来让Swing看起来还过得去。

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.

我们现在最好的选择(只是一个观点,没有任何秘密知识)是Oracle的某人(或者OpenJDK的贡献者)将会购买retina mac并在Java 8中修复它。我不认为苹果会通过提供Java 6补丁来修复它,因为苹果的那个家伙说他们只是恢复了与渲染到Quartz有关的代码。它确实给出了预期的结果,但是与私有的OS X内部构件紧密相连,而这些内部构件并不是开源的。



粤ICP备14056181号  © 2014-2020