後續問題to my other one;JSplitPane + MiGLayout:如何啓用比例自動調整
如何啓用比例調整大小?我認爲這會工作,但它並不:
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, "push, grow");
splitpane.setTopComponent(new JButton("top"));
splitpane.setBottomComponent(new JButton("bottom"));
splitpane.setDividerLocation(0.333);
frame.pack();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
}
我想是上/下按鈕大小的比例是恆定的,當我調整整個框架。 (預設比例爲1:2)
我該怎麼做?
啊哈!謝謝,我期待setDividerLocation的工作,當它不,我不知道該怎麼做。 – 2011-01-31 17:31:18