下面是我的简化代码示例:
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\U 251
1条答案
按热度按时间relj7zay1#
看来这是你当地的问题。我看不到这个神器。