用于 AWT / Swing 的 Java JDK 1.7 中的 Apple Retina 显示支持
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/15181079/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Apple Retina Display Support in Java JDK 1.7 for AWT / Swing
提问by kalefranz
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 不支持 Apple Macbook Pro 上的 Retina 显示。例如,Netbeans 几乎无法忍受在 Retina 显示器上运行超过几分钟并使用 JDK 1.7。
This has been somewhat addressed in a StackExchange question here, and quoting one specific post:
这已在此处的 StackExchange 问题中有所解决,并引用了一篇特定文章:
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.
Apple 的 Java 6 JRE 将支持 HiDPI,但是 Oracle 的 Java 7 JRE 目前不支持。它也不适用于 Java 8 的最新开发版本。Swing 和 JavaFX 应用程序在 Retinia MacBook 上模糊不清。这就是 IntelliJ 仍然在 Java 6 下运行的原因。
My question is more specific than what is asked by the OP of the above thread.
我的问题比上述线程的 OP 提出的问题更具体。
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 社区是否会对这个问题做出相当的反应,或者在 Swing 之前预计会有实质性的延迟(几个月到一年或更长时间)在 Java 7 中是否与 Apple Retina 显示器兼容?
采纳答案by Thunderforge
Java 7u40 Early Access now supports HiDPI (Retina) displays, as shown by this changelog. So retina support is now available on:
Java 7u40 Early Access 现在支持 HiDPI (Retina) 显示,如此更新日志所示。因此,视网膜支持现在可用于:
- Java 6
- Java 7u40ea or greater
- Java 8
- 爪哇 6
- Java 7u40ea 或更高版本
- 爪哇 8
回答by Lubos
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
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.
据此,它应该针对 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
问候, Lubos
回答by Konstantin Bulenkov
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/
从 1.7.0_40ea 开始,Oracle 完全支持 Retina。但是,缺少用于 Retina 的 API。例如,不支持像 Apple JDK 中的 HiDPIScaledImages。您可以在此处找到有关 Oracle JDK 中 Retina 支持的一些很酷的技巧http://bulenkov.com/2013/06/23/retina-support-in-oracle-jdk-1-7/
回答by SiCN
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).
根据我几个月前读到的一个长线程(http://lists.apple.com/archives/java-dev/2012/Oct/msg00127.html),在 Swing 中获得 Retina 的唯一方法是安装 Apple 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 演示应用程序,可在 App Store 上获得)相同,它的渲染效果似乎也比普通 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 Snapshot 版本,我还可以确认几乎没有做任何工作来使 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 中修复它。我认为 Apple 不会修复它通过提供 Java 6 修复程序,因为 Apple 的那个人说他们只是将与渲染相关的代码恢复到 Quartz。它确实提供了预期的结果,但与未开源的专有 OS X 内部结构密切相关。