奇怪的摆动边框神器

问题描述

这是我的简化代码示例:

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));
        Box.add(splitPane);

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

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

它产生以下结果:

enter image description here

如果您仔细观察左下角,可能会发现奇怪的边框变形:

enter image description here

有人知道错在哪里吗? 在macOS上测试,jdk1.8.0_251

解决方法

enter image description here

似乎这是您的本地问题。我看不到这个人工制品。