سؤال

I am wanting to grow only the last component in a panel to fill the remaining vertical space.

I currently have:

panel.setLayout(new MigLayout("inset 0, filly", "[grow, fill, right][grow, fill, left]"));

Which adds padding after each component in order to fill the remaining vertical space. Is there a way to tell MigLayout not to add the padding and grow the last row?

The last row is docked incase that changes anything:

panel.add(new JScrollPane(getTable()), "newline, dock south");

Oh, one more thing I forgot to mention (and this is probably important) The amount of rows isn't know at compile time.

هل كانت مفيدة؟

المحلول

Looks like the dock indeed makes a difference, replacing it with pushy growing cell constraint (and no filly in the layout constraint) works fine. Might be an option if you can live without the dock:

panel.add(new JScrollPane(new JTable(8, 5)), "span, pushy, growy");

نصائح أخرى

I have solved this by adding the component constraint of: height :100%: and removing the filly layout constraint.

My understanding is that this tells the component that it has no minimum size and the preferred size is 100% of it's container. This means that it will take up as much room as possible.

So when you do use the size constraint :pref: I believe it's saying "Up to the specified size`

And when you do min:: I think that resolves to "at least the specified size"?

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top