想在切分窗口JSplitPane下增加JPanel,但JPanel无法完全最大化,其上方有空白窄边, 使用setLocation(),setBounds()也无法消除!不知道什么原因?以下是相关代码:
JPanel sp1 = new JPanel();
JPanel sp2 = new JPanel();
splitPane.setLeftComponent(sp1);
splitPane.setRightComponent(sp2);
JPanel plot = new JPanel();
plot.setPreferredSize(new Dimension(2000,1000));
JScrollPane scrollPane = new JScrollPane(plot);
scrollPane.setPreferredSize(new Dimension(1000,500));
scrollPane.setVisible(true);
// scrollPane.setLocation(0,-10); // 不解决问题
// scrollPane.setBounds(0,-10,1000,500); // 不解决问题
sp2.add(scrollPane);
目前的结果如下:
怎么消除这个空白区?