好吧,我对 MigLayout 很陌生,并且已经在白皮书和快速入门中阅读过它,但这还不够。我在其下方放置了一个面板,我希望一个面板占据 30% 的窗口,而其他面板则占 70%。当窗口被调整大小(最大化)时,组件搞砸了。代码如下:
Mig_tmp1(){
j=new JFrame("test");
j.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
j.setLayout(new MigLayout("debug,fill","[70px]5[:70:250,grow]","[:100:]10[fill,grow]"));
one=new JPanel();
one.setBackground(Color.red);
two=new JPanel();
two.setBackground(Color.ORANGE);
three=new JPanel();
three.setBackground(Color.BLUE);
j.add(one,"wrap,span,grow");
j.add(two,"grow");//,"w 40!");
j.add(three,"grow");
//j.pack();
j.setSize(400, 600);
j.setVisible(true);
}