2
我在這裏做錯了事情:我想在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);
}
}
太好了 - 謝謝! – 2011-01-31 15:17:17