How to make first column to grow, while all other columns to have minimal size in MigLayout?

106 views Asked by At

The code:

public class Try_Grow_01 {

    public static void main(String[] args) {

        JFrame frame = new JFrame();

        frame.setLayout(new MigLayout("fill, debug", "[fill]5[5]"));

        frame.add(new JButton("one"), "");
        frame.add(new JButton("two"), "");
        frame.add(new JButton("three"), "");

        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        frame.pack();
        frame.setLocationRelativeTo(null);
        frame.setVisible(true);

    }

}

result is

enter image description here

i.e. two right cells also grow, while I want them not to.

How to accomplish?

1

There are 1 answers

0
dic19 On BEST ANSWER

If you want the first cell grow and fill all available space then you must create the MigLayout as follows:

frame.setLayout(new MigLayout("fill, debug", "[fill, grow][][]"));

enter image description here

If you want the first cell grow but without fill the available space then you must create the MigLayout as follows:

frame.setLayout(new MigLayout("fill, debug", "[grow][][]"));

enter image description here

Take a look to page 6 of Quick Start guide