奇怪的摆动边框瑕疵

huangapple go评论79阅读模式
英文:

Strange swing border artifact

问题

以下是翻译好的代码部分:

public class TestPanel extends JPanel {

    private static void createAndShowGUI() {
        JFrame myFrame = new JFrame("");
        myFrame.setBounds(new Rectangle(100, 100, 240, 180));
        myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JPanel box = new JPanel(null);
        box.setBackground(Color.BLUE);

        JPanel left = new JPanel();
        left.setOpaque(false);

        JPanel right = new JPanel();
        right.setOpaque(false);

        JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, left, right);
        splitPane.setResizeWeight(0.5);
        splitPane.setOpaque(false);

        box.setLayout(new BorderLayout());
        box.setBorder(new EmptyBorder(10, 10, 10, 10));
        box.add(splitPane);

        myFrame.getContentPane().add(box, BorderLayout.CENTER);
        myFrame.setVisible(true);
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(TestPanel::createAndShowGUI);
    }
}

它产生以下结果:

奇怪的摆动边框瑕疵

如果您仔细看左下角,您可能会注意到奇怪的边框失真:

奇怪的摆动边框瑕疵

有人知道出了什么问题吗?
在 macOS、jdk1.8.0_251 上进行了测试。

英文:

Here is my simplified code example:

public class TestPanel extends JPanel {

    private static void createAndShowGUI() {
        JFrame myFrame = new JFrame("");
        myFrame.setBounds(new Rectangle(100, 100, 240, 180));
        myFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

        JPanel box = new JPanel(null);
        box.setBackground(Color.BLUE);

        JPanel left = new JPanel();
        left.setOpaque(false);

        JPanel right = new JPanel();
        right.setOpaque(false);

        JSplitPane splitPane = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, left, right);
        splitPane.setResizeWeight(0.5);
        splitPane.setOpaque(false);

        box.setLayout(new BorderLayout());
        box.setBorder(new EmptyBorder(10, 10, 10, 10));
        box.add(splitPane);

        myFrame.getContentPane().add(box, BorderLayout.CENTER);
        myFrame.setVisible(true);
    }

    public static void main(String[] args) {
        SwingUtilities.invokeLater(TestPanel::createAndShowGUI);
    }
}

It produces following result:

奇怪的摆动边框瑕疵

If you look closely at the bottom left corner, you may notice strange border distortion:

奇怪的摆动边框瑕疵

Does anyone have an idea what is wrong?
Tested on macos, jdk1.8.0_251

答案1

得分: 1

Sure, here's the translated content:

似乎这是您本地的问题。我无法看到这个工件。

英文:

奇怪的摆动边框瑕疵

Seems that this is your local problem. I can't see this artifact.

huangapple
  • 本文由 发表于 2020年8月21日 02:52:48
  • 转载请务必保留本文链接:https://go.coder-hub.com/63511508.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定