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

StackOverflow https://stackoverflow.com/questions/20362115

  •  28-08-2022
  •  | 
  •  

문제

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?

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top