java - apple.awt.brushMetal在 mac 10.7 视网膜上看起来奇怪的行为

标签 java macos jvm retina-display look-and-feel

我使用的是 10.7.4 视网膜。当我使用 getRootPane().putClientProperty("apple.awt.brushMetalLook", true);
时,我的 JFrame 看起来不符合预期 我尝试在 JVM 1.6.0_51 上运行它。它看起来像这样:
enter image description here

甚至尝试使用 -d32 和 -d64。

当我在最新的 JVM 1.7.0_25 上运行它时,它将如下所示:
enter image description here

当我在 10.6 mac 上的 JVM 1.6.0_15 上运行它时,两者看起来都不像应有的样子:
enter image description here

有办法解决这个问题吗?视网膜分辨率可能是原因吗? 这篇文章与之前询问的这篇文章有点相关:JFrame is lagging on resize

最佳答案

是的,您可以通过尽早放置客户端属性来解决这个问题。

Documentation说:

WARNING: This property must be set before the heavyweight peer for the Window is created. Once addNotify() has been called on the component, causing creation of the heavyweight peer, changing this property has no effect.

这是一个 MWE:

import javax.swing.JFrame;

public class Main {
    public static void main(String[] args) {
        JFrame frame = new JFrame("Hello World");
        frame.getRootPane().putClientProperty("apple.awt.brushMetalLook", Boolean.TRUE);
        frame.setSize(400, 300);
        frame.setVisible(true);
    }
}

Screenshot of MWE

如果你交换frame.setVisible(true);和我们放置客户端属性的部分,你会得到一个黑框(Mac OS 10.9.4,Java 1.8.0_05):

Bad example

希望对您有帮助。

关于java - apple.awt.brushMetal在 mac 10.7 视网膜上看起来奇怪的行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18542062/

相关文章:

java , Swing ;简单的 gui 在哪里创建对象

java - JVM 崩溃时异常中显示奇怪的路径

java - JVM 堆栈内存

.net - 压缩对象指针的目的是什么?

java - 我可以使用 Eclipse 找出哪个线程正在运行吗?

java - 如果只给出事件点,如何绘制图表?

macos - 通过brew安装后如何在Mac OS上使用Vim 7.4?

objective-c - Cocoa Webview - 伪装 webview 作为原生控件

java - 如何在 Spring Boot 中更改允许的 header

java - Eclipse 3.4.2 在 Mac OSX 上编译 Java 1.6