我创建了一个没有任何按钮的OptionDialog
,并在其中使用MigLayout
作为其布局使用JPanel
。那JPanel
里面有另一个JPanel
。JPanel上的边距与MigLayout
这两个面板似乎都有一个边缘在它的外面。也许它是在容器上填充。无论哪种方式,我想要一种方法来摆脱它们。
我该如何摆脱这些边距?在图片中,它们是JPanel周围的灰色和深橙色边框。
这里是面板代码:
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);
这里是OptionDialog代码:
DocumentPanel panel = new DocumentPanel(controller.getDocuments());
JOptionPane.showOptionDialog(null, panel, "Enroll now!", JOptionPane.DEFAULT_OPTION,
JOptionPane.PLAIN_MESSAGE, null, new Object[] {}, null);
你可以显示一些代码。 – tarrsalah 2013-05-01 21:49:32
我粘贴了代码。谢谢你的帮助。 – ajon 2013-05-01 21:53:58