我使用的是 10.7.4 视网膜。当我使用 getRootPane().putClientProperty("apple.awt.brushMetalLook", true);
时,我的 JFrame 看起来不符合预期
我尝试在 JVM 1.6.0_51 上运行它。它看起来像这样:
甚至尝试使用 -d32 和 -d64。
当我在最新的 JVM 1.7.0_25 上运行它时,它将如下所示:
当我在 10.6 mac 上的 JVM 1.6.0_15 上运行它时,两者看起来都不像应有的样子:
有办法解决这个问题吗?视网膜分辨率可能是原因吗? 这篇文章与之前询问的这篇文章有点相关:JFrame is lagging on resize
最佳答案
是的,您可以通过尽早放置客户端属性来解决这个问题。
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);
}
}
如果你交换frame.setVisible(true);
和我们放置客户端属性的部分,你会得到一个黑框(Mac OS 10.9.4,Java 1.8.0_05):
希望对您有帮助。
关于java - apple.awt.brushMetal在 mac 10.7 视网膜上看起来奇怪的行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18542062/