JSplitPane + MiGLayout:如何启用自动调整
问题描述:
我在这里做错了事情:我想在JSprame中的JPanel中的JSplitPane中有两个JButton,其中按钮填充JSplitPane。JSplitPane + MiGLayout:如何启用自动调整
这里就是我得到的,当我调整的JFrame:
按钮留在他们的正常大小,调整JSplitPane不允许adjusting.something
我该如何解决这个问题?
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JSplitPane;
import net.miginfocom.swing.MigLayout;
public class SplitPaneQuestion {
public static void main(String[] args) {
JFrame frame = new JFrame("SplitPaneQuestion");
JPanel panel = new JPanel();
frame.setContentPane(panel);
panel.setLayout(new MigLayout("","[]","[grow]"));
JSplitPane splitpane = new JSplitPane(JSplitPane.VERTICAL_SPLIT);
panel.add(splitpane, "");
splitpane.setTopComponent(new JButton("top"));
splitpane.setBottomComponent(new JButton("bottom"));
frame.pack();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
答
添加 “推” 和 “成长” 的约束上,以将拆分窗格中,像这样:
panel.add(splitpane, "push, grow");
太好了 - 谢谢! – 2011-01-31 15:17:17