使用 MigLayout 的 JPanel 上的边距

ajo*_*jon 2 java swing jpanel miglayout

我创建了一个OptionDialog没有任何按钮的项目,并JPanel在其中放入了一个用于MigLayout其布局的项目。那里面JPanel还有另一个。JPanel

这两个面板的外侧似乎都有边距。也许它是容器上的填充物。不管怎样,我想要一种摆脱它们的方法。

我怎样才能摆脱这些边距?在图片中,它们是 JPanel 周围的灰色和深橙色边框。

J面板

这是面板代码:

setBackground(new Color(239,209,59));
setLayout(new MigLayout("wrap 1"));
JLabel title = new JLabel("Enroll Today!", JLabel.CENTER);
Font f = title.getFont().deriveFont((float)36);
title.setFont(f);
add(title);
JPanel docsPanel = new JPanel();
docsPanel.setBorder(BorderFactory.createEmptyBorder());
docsPanel.setLayout(new MigLayout("wrap 1", "", "[grow,fill]"));
docsPanel.setBackground(new Color(255,235,115));
for (final Document d : docs){
    JButton doc = new JButton("* "+d.getName());
    doc.setFont(f.deriveFont((float)24));
    doc.setBorder(null);
    doc.setContentAreaFilled(false);
docsPanel.add(doc);
}
add(docsPanel);
Run Code Online (Sandbox Code Playgroud)

这是选项对话框代码:

DocumentPanel panel = new DocumentPanel(controller.getDocuments());
JOptionPane.showOptionDialog(null, panel, "Enroll now!", JOptionPane.DEFAULT_OPTION, 
                             JOptionPane.PLAIN_MESSAGE, null, new Object[] {}, null);
Run Code Online (Sandbox Code Playgroud)

tar*_*lah 5

"ins 0, wrap 1"盲目地在构造函数中尝试MigLayout