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