需要在JFrame上为macosx El Capitan圆角。

时间:2022-04-20 06:04:28

I notice that nearly every application but mine has a window border with 4 rounded corners. Mine has rounded corners only on the top. Below is my SSCCE and it does not produce what I want even when I vary the jdk version (7 and 8) and vary the laf (Metal, Nimbus, CDE/Motif, Mac OS X). In my early tests, I tried undecorating the frame but that causes more problems than it solves.

我注意到几乎每个应用程序都有一个窗口边框,有四个圆角。我的圆角只有在顶部。下面是我的SSCCE,它不会产生我想要的东西,即使我改变了jdk版本(7和8),并且改变了laf(金属,Nimbus, CDE/Motif, Mac OS X)。在我的早期测试中,我尝试了不装饰框架,但是它会导致更多的问题。

import javax.swing.JFrame;

public class TestMacFrame extends JFrame {

    public TestMacFrame() {
        super();
        setSize(200, 200);
        setLocationRelativeTo(null);
        setDefaultCloseOperation(EXIT_ON_CLOSE);
        setVisible(true);
    }

    public static void main(String[] args) {
        new TestMacFrame();
    }
}

需要在JFrame上为macosx El Capitan圆角。

Here is what it looks like on Yosemite with Java 8 and the default laf. The corners are rounded but it's difficult to tell unless you zoom in on the image. It seems as though the window manager is doing something different but I have no idea how to get a handle on it.

这是Yosemite上的Java 8和默认laf的样子。角是圆形的,但除非你放大图像,否则很难分辨。似乎窗口管理器在做一些不同的事情,但我不知道如何处理它。

需要在JFrame上为macosx El Capitan圆角。

1 个解决方案

#1


0  

After installing Java 8 on Yosemite, I can run the code and see 4 rounded corners.

在Yosemite上安装Java 8之后,我可以运行代码并看到4个圆角。

#1


0  

After installing Java 8 on Yosemite, I can run the code and see 4 rounded corners.

在Yosemite上安装Java 8之后,我可以运行代码并看到4个圆角。