OptionDialog
ボタンのないを作成し、レイアウトJPanel
に使用する を入れました。MigLayout
その中JPanel
にもう一つJPanel
ある。
これらのパネルはどちらも外側に余白があるようです。たぶん、コンテナのパディングです。いずれにせよ、それらを取り除く方法が欲しいです。
これらのマージンを取り除くにはどうすればよいですか? 写真では、JPanels の周りの灰色と濃いオレンジ色の境界線です。
パネルコードは次のとおりです。
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);